自定义 QGestureRecognizer 和 QTouchEvents
我想在 Qt 应用程序中使用自定义输入设备进行多点触控输入。我计划根据我的原始输入数据创建 QTouchEvents。我还想生成自定义手势。
据我了解,我必须继承 QGestureRecognizer,为我想要控制的小部件创建一个 QGesture,并实现 recognize() 来过滤我的 QTouchEvents 并在适当的时候触发手势。
现在我有两个问题:
这是正确的做事方式吗?
当我已经在 QGestureRecognizer 中使用 QTouchEvents 时,如何确保它们仍然到达我的小部件(例如用于拖动)?或者与我的小部件的所有交互都应该以手势的形式吗?
I want to use a custom input device for multitouch input in a Qt application. I plan to create QTouchEvents based on my raw input data. I also want to generate custom gestures.
As far as I understand, I have to subclass QGestureRecognizer, create a QGesture for the widget I want to control and implement recognize() to filter my QTouchEvents and trigger the gesture when appropriate.
Now I have two questions:
Is this the correct way to do things?
How do I make sure that QTouchEvents still reach my widget (e.g. for dragging) when I already use them in my QGestureRecognizer? Or should all interaction with my widget be in form of gestures?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
到目前为止我在这个问题上的进展,如果有人发现自己处于类似的情况:
1.:这可能是正确的方法,但它不起作用。即使在应用程序中注册了我的识别器后,它也不会收到任何 QTouchEvents。因此,我将识别器安装为目标小部件的事件过滤器。
2.:至少在使用eventFilter时,可以将事件传递给原始接收者。请参阅http://doc.qt.io/qt-5/qobject.html#事件过滤器。
My progress on this matter so far, should anyone find themselves in a similar situation:
1.: It may be the right way but it doesn't work. Even after registering my recognizer with the application, it does not receive any QTouchEvents. I therefore installed my recognizer as an eventFilter for the target widget.
2.: At least when using an eventFilter, one can pass the event to the original receiver. See http://doc.qt.io/qt-5/qobject.html#eventFilter.