QT 中的手指滚动?
我已经对我的 QListWidget 之一实现了手指滚动。 我参考了 http://www.developer.nokia.com/Community/Wiki/Qt_Kinetic_scrolling__-_from_idea_to_implementation
现在的问题是 QListWidget 的 on_current_row_changed 事件被触发当我上下滚动我的列表时。 我如何避免仅在单击时出现这种情况,它的行为应该像单击而不是滚动。
I have implemented Finger Scrolling to one of my QListWidget.
I have taken refernce from
http://www.developer.nokia.com/Community/Wiki/Qt_Kinetic_scrolling_-_from_idea_to_implementation
Now the problem is on_current_row_changed event of QListWidget gets fired when i scroll up and down my List.
How i can avoid this on click only it should behave like click not on Scroll.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从 Qt5 开始,这很简单:
对于触摸屏,使用
TouchGesture
而不是LeftMouseButtonGesture
。如果小部件未继承
QAbstractScrollArea
(例如QWebView
):请务必将小部件的大小调整为其内容大小。
Starting from Qt5 this is as simple as:
For touch screens use
TouchGesture
instead ofLeftMouseButtonGesture
.If the widget doesn't inherit
QAbstractScrollArea
(e.g.QWebView
):Be sure to resize the widget to its content size.
您需要测试手指是否在 mousePress 和 mouseRelease 之间移动。您可以提取按下的位置,因此如果将其存储在中间变量中,然后根据 mouseRelease 的位置对其进行测试(例如使用 QPoint::manhattanLength()),您可以判断手指是否已移动。如果有,则用户正在滚动,如果没有,则他们正在单击。
编辑:查看您链接到的代码,他们已经在执行上述操作。我们可以看看您的更多重新实现吗?
You need to test whether the finger has moved between mousePress and mouseRelease. You can extract the position of the press, so if you store it in an intermediate variable, then test it against the position of the mouseRelease (say using QPoint::manhattanLength()), you can tell whether the finger has moved. If it has, the user is scrolling, if not, they're clicking.
EDIT: Looking at the code you've linked to, they're already doing the above. Could we see some more of your reimplemenation?