QTouchEvent 在 Windows 8 下无法使用 Qt 4.7.4 触发?

发布于 2024-12-27 05:54:24 字数 1136 浏览 2 评论 0原文

我在配备 4 点触摸屏的 Acer W501 x86 平板电脑上运行的 Windows 8 下遇到 QT 触摸/多点触摸支持问题。

我有一个 QGraphicsView 小部件,我已经完成了

setAttribute(Qt::WA_AcceptTouchEvents);

该小部件的父级有一个 eventFilter 方法:

bool MyGUI::eventFilter(QObject* pObject, QEvent* pEvent)
{
    QEvent::Type eType = pEvent->type();
    if (pObject == _uiWindow._multitouchArea)
    {
        if ((eType == QEvent::TouchBegin) || (eType == QEvent::TouchEnd) || (eType == QEvent::TouchUpdate))
        {
            // invoke multi touch event handling here
            _handleTouchEvent(pEvent);
        }
        else if ((eType == QEvent::MouseButtonPress) || (eType == QEvent::MouseButtonRelease) || (eType == QEvent::MouseMove))
        {
            // invoke mouse based handling here
            _handleMouseEvent(pEvent);
        }   
    }
    else
    {
        return pObject->event(pEvent);
    }

    return false;
}

它安装在 QGraphicsViewWidget 上。

现在我明白 Qt 默认情况下将单点触摸事件解释为鼠标事件并将它们发送到应用程序。但是,无论我多么努力地将触摸屏与我的身体的任何部分混合在一起,我都无法触发任何 TouchBegin/TouchUpdate/TouchEnd 事件...

我在这里缺少什么吗?

谢谢大家!

I am having an issue with QT touch/multitouch support under Windows 8 running on an Acer W501 x86 tablet with a 4-point touch screen.

I have a QGraphicsView widget on which I've done

setAttribute(Qt::WA_AcceptTouchEvents);

The widget's parent has an eventFilter method:

bool MyGUI::eventFilter(QObject* pObject, QEvent* pEvent)
{
    QEvent::Type eType = pEvent->type();
    if (pObject == _uiWindow._multitouchArea)
    {
        if ((eType == QEvent::TouchBegin) || (eType == QEvent::TouchEnd) || (eType == QEvent::TouchUpdate))
        {
            // invoke multi touch event handling here
            _handleTouchEvent(pEvent);
        }
        else if ((eType == QEvent::MouseButtonPress) || (eType == QEvent::MouseButtonRelease) || (eType == QEvent::MouseMove))
        {
            // invoke mouse based handling here
            _handleMouseEvent(pEvent);
        }   
    }
    else
    {
        return pObject->event(pEvent);
    }

    return false;
}

which is installed on the QGraphicsViewWidget.

Now I understand that Qt by default interprets single point touch events as mouse events and sends them to the application like that. However, I've been unable to trigger any TouchBegin/TouchUpdate/TouchEnd events whatsoever no matter how hard I mash the touch screen with any part(s) of my anatomy...

Is there something that I am missing here?

Thank you all!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

很酷又爱笑 2025-01-03 05:54:24

您是否尝试在图形视图的 viewport() 上安装事件过滤器?
这是事件发送的地方。

Did you try installing the event filter on the viewport() of the graphicsview?
This is where the events are sent.

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