0
I need to enable the scrollbar in a widget qwebview
, and put the automatic scrolling, but I couldn’t find any information on how to do this in python.
I tried to do so:
self.qwebview.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
But it didn’t work
I tried so:
self.qwebview.page().mainFrame().setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
Didn’t work..
Where do I use this setVerticalScrollBarPolicy
? And how do I get the vertical bar to appear?
What code do you have so far?
– PauloHDSousa
Actually, Paulo, I create the webview by qtdesign, so I already get it ready in my class when I upload the file. ui I did some research and the command is something like: setVerticalScrollBarPolicy But I couldn’t apply it to the qwebview variable self.qwebview.setVerticalScrollBarPolicy(Qt.Scrollbaralwayson) Type like this didn’t work, it should be something simple, but I’m not finding an example that works
– Mega Anim
The manual help in these cases. See if this solves:
self.qwebview.page().mainFrame().setScrollBarPolicy(
Qt.Vertical
, Qt.ScrollBarAlwaysOn )
- The function requires two parameters, which scrollbar, and which policy.– Bacco
To complete:
setVerticalScrollBarPolicy
is a method ofQAbstractScrollArea
, and theQWebFrame
is not descended fromQAbstractScrollArea
, therefore this method does not apply. However, in the Qt manual, linked above, theQWebFrame
has the methodsetScrollBarPolicy
, that serves to define whether the scrollbar appears always, never, or only when needed.– Bacco
I managed using this method gave straight, now I lack to figure out a way to roll it until the end automatically, and my application will be complete
– Mega Anim
@Megaanim I voted to reopen your question, if you give 4 more votes, I put it better formatted as an answer instead of a comment. As for scrolling to the end, it depends a lot on how you will do. If the information is changing all the time, you can do with JS yourself. Calling by Qt, you can use
setScrollBarValue( Qt.Vertical, VALOR )
. To know the maximum, has the propertyscrollBarMaximum( Qt.Vertical )
. A gambiarra would be for a very high value, that control will cover it to the size of the page, anyway. Using the Maximum is safer.– Bacco
I did so: self.qwebview.page(). mainframe(). setScrollBarValue( Qt.Vertical, self.qwebview.page().mainframe().scrollBarMaximum( Qt.Vertical ) ) Ta working more or less, but it doesn’t go to the end, always leaves a little bit.. But I think this happens because of javascript.. The content constantly updates, every time it updates I call a python object inside the own javascript, then I can call functions inside the python, then I call the scrolling function() with this function inside..
– Mega Anim