How to enable vertical scrollbar in python qwebview?

Asked

Viewed 175 times

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?

  • 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

  • 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.

  • To complete: setVerticalScrollBarPolicy is a method of QAbstractScrollArea, and the QWebFrame is not descended from QAbstractScrollArea, therefore this method does not apply. However, in the Qt manual, linked above, the QWebFrame has the method setScrollBarPolicy, that serves to define whether the scrollbar appears always, never, or only when needed.

  • 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

  • @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 property scrollBarMaximum( 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.

  • 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..

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.