当QWebView滚动到末尾时捕获信号
当用户在 QWebView 小部件中使用鼠标滚动时,我可以知道他是否到达了网页内容的开头/结尾吗?
我可以在里面放置一个 QWebView::wheelEvent() ,但是我如何知道滚动位置?
谢谢 !
When a user scroll with his mouse within a QWebView widget , can i know if he got to the head / end of web contents ?
I may place a QWebView::wheelEvent() inside , but how can i know about the scroll positions ?
Thanks !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以检查页面主机的
scrollPosition
:You can check the
scrollPosition
of the page's mainframe:当滚动位置更改时,我在搜索实际信号时发现了这个问题。
有可以使用的
QWebPage::scrollRequested
信号。 文档说 只要内容出现,就会发出此信号rectToScroll 给出的需要向下滚动 dx 和 dy 并且没有设置视图。,但是最后一部分是错误的,信号实际上总是发出。我贡献修复了这个问题到Qt,所以这可能会被纠正为一旦文档更新。
(原帖如下)
QWebView 不提供此功能,因为 WebKit 管理滚动区域。
我最终扩展了 PaintEvent 来检查滚动位置,并在滚动位置发生变化时发出信号。
PyQt 代码发出带有百分比的
scroll_pos_changed
信号:I found this question when searching for an actual signal when the scroll position was changed.
There is the
QWebPage::scrollRequested
signal which can be used. The documentation says This signal is emitted whenever the content given by rectToScroll needs to be scrolled dx and dy downwards and no view was set., however the last part is wrong, the signal is actually always emitted.I contributed a fix for this to Qt, so this will probably be corrected as soon as the docs are updated.
(original post following)
QWebView doesn't provide this because WebKit manages the scroll-area.
I ended up extending
paintEvent
to check the scroll position there, and emit a signal when it has changed.PyQt code which emits a
scroll_pos_changed
signal with a percentage: