将Qwebengineviewer scrollbar设置在页面底部
我在QMainWindow中使用了Qwebengineviewer窗口小部件,我希望每次打开应用程序时,它总是在页面的botom上都有滚动条。我发现了一些建议,但它们似乎对我有用。例如,我找到了一个适合的答案
self.webEngine.page().runJavaScript("window.scrollTo(0, 0);")
。我在qwebengineviewer中找不到它(我很确定这是从以前的QT版本中找到的)。这是C ++中提供的示例:
webView->page()->mainFrame()->setScrollBarValue(Qt::Vertical, webView->page()->mainFrame()->scrollBarMaximum(Qt::Vertical));
事先感谢您的帮助!
I'm using a QWebEngineViewer widget in my QMainWindow and I want it to have the scrollbar always at the botom of the page every time I open my application. I have found some suggestions but none of them seem to work for me. For example, a posible answer i found used .runJavaScript() to modify de scrollbar position from there, but no matter what I but in the x or y axis the scrollbar doesn't move:
self.webEngine.page().runJavaScript("window.scrollTo(0, 0);")
Another suggestion used the setScrollBarValue() function, but I can't find it in QWebEngineViewer (I'm pretty sure that is from a previous version of qt). Here is the example provided in C++:
webView->page()->mainFrame()->setScrollBarValue(Qt::Vertical, webView->page()->mainFrame()->scrollBarMaximum(Qt::Vertical));
Thanks in advance for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是我为解决问题所做的。首先,我实现了如下:
document.body.scrollheight有助于在页面底部找到滚动条。
然后,我将scrolldown连接到了加载信号:
谢谢@musicamante的建议!
Here is what I did to solve the problem. First I implemented scrollDown as follows:
document.body.scrollHeight helps in locating the scrollbar at the bottom of the page.
Then I connected scrollDown to the loadFinished signal:
Thanks @musicamante for the suggestion!