PyQt4 and QtWebKit - how to auto scroll the view?
Question
I got a QtWebKit.QWebView
widget in a PyQt application window that I use to display text and stuff for a chat-like application.
self.mainWindow = QtWebKit.QWebView()
self.mainWindow.setHtml(self._html)
As the conversation gets longer the vertical scrollbar appears.
What I'd like to get, is to scroll the displayed view to the bottom when it's needed. How can I do it? Or, maybe, I shouldn't use QWebView
widget for this?
OTHER TIPS
For (Py)Qt 4.5, use frame's scroll position, e.g. self._html.page().mainFrame().setScrollPosition. See QWebFrame::setScrollPosition() function..
Maybe JavaScript is the easiest way, but you may also use evaluateJavaScript
function of QWebView
:
self.page().mainFrame().evaluateJavaScript("window.scrollTo(0, "+str(self.init_ypos)+");")
where self
is a class Browser(QWebView)
(self.mainWindow
for you).
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow