Qt中有选择地忽略鼠标事件

发布于 2024-12-21 11:55:32 字数 726 浏览 3 评论 0原文

我正在编写一个从 3 只老鼠获取输入的应用程序。其中 2 个鼠标用于手势,它们的输入是单独处理的,第三个鼠标应该正常工作。 我已经成功安装了一个运行我自己的鼠标处理代码 (processMouse()) 的事件过滤器(见下文)。

但是,当尝试让过滤器忽略来自某些鼠标的事件(由 processMouse() 的布尔返回值确定)时,不会忽略任何内容。

我尝试使用正常的真/假返回值,将事件重置为“无”事件,调用它的忽略函数,但即使我告诉它忽略该事件,鼠标仍然保持移动。

bool MainWindow::eventFilter(QObject *obj, QEvent *event){
    if ((event->type() == QEvent::MouseMove) ||
        (event->type() == QEvent::MouseButtonPress)){
        if (configured){
            if (!processMouse()){
                //event->ignore();
                //event = new QEvent(QEvent::None);
            }
        }
        return true;

    }
    return false;
}

我如何有选择地忽略事件过滤器中的MouseMove 事件?

I am writing an application that gets input from 3 mice. 2 of the mice are used for gestures and their input is handled separately, the 3rd should function as normal.
I have successfully installed an eventfilter (see below) that runs my own mouse-processing code (processMouse()).

However, when trying to get the filter to ignore the events from certain mice (determined by the boolean return value of processMouse()), nothing gets ignored.

I have tried using the normal true/false return values, resetting the event to a "None" event, calling it's ignore function, but the mouse still keeps moving even when I tell it to ignore the event.

bool MainWindow::eventFilter(QObject *obj, QEvent *event){
    if ((event->type() == QEvent::MouseMove) ||
        (event->type() == QEvent::MouseButtonPress)){
        if (configured){
            if (!processMouse()){
                //event->ignore();
                //event = new QEvent(QEvent::None);
            }
        }
        return true;

    }
    return false;
}

How can I selectively ignore MouseMove events from an eventfilter?

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

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

发布评论

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

评论(1

花伊自在美 2024-12-28 11:55:32

最终通过使用名为“ManyMouse”的第三方库解决了这个问题,该库单独接收每个鼠标的输入。

This was eventually solved by using a 3rd party library named "ManyMouse", which receives each mouse's input separately.

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