自定义 QGestureRecognizer 和 QTouchEvents

发布于 2024-12-20 18:08:06 字数 356 浏览 3 评论 0原文

我想在 Qt 应用程序中使用自定义输入设备进行多点触控输入。我计划根据我的原始输入数据创建 QTouchEvents。我还想生成自定义手势。

据我了解,我必须继承 QGestureRecognizer,为我想要控制的小部件创建一个 QGesture,并实现 recognize() 来过滤我的 QTouchEvents 并在适当的时候触发手势。

现在我有两个问题:

  1. 这是正确的做事方式吗?

  2. 当我已经在 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:

  1. Is this the correct way to do things?

  2. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

别在捏我脸啦 2024-12-27 18:08:06

到目前为止我在这个问题上的进展,如果有人发现自己处于类似的情况:

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文