Disabling QGraphicsWebView scrollbars
-
11-06-2021 - |
Question
I want to disable the scrollbars in a QGraphicsWebView
. It says in the documentation:
"... if the Web page contents is larger than that, scrollbars will be shown if not disabled explicitly."
I can't seem to find a way to disable the scrollbars.
I need to disable the scrollbars because I want to implement scrolling on drag and I don't want them to be shown.
La solution
You can set the scrollbar behaviour on QWebFrame. What you probably want is something like:
QWebFrame* frame = webView->page()->mainFrame();
frame->setScrollBarPolicy( Qt::Horizontal, Qt::ScrollBarAlwaysOff );
frame->setScrollBarPolicy( Qt::Vertical, Qt::ScrollBarAlwaysOff );
Autres conseils
The page itself needs to have appropriate CSS to prevent the scrollbars from appearing, e.g. body {overflow: hidden}
.
If you don't have control over the page contents, resizesToContents might be the property you're looking for.
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow