Qt中有选择地忽略鼠标事件
我正在编写一个从 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最终通过使用名为“ManyMouse”的第三方库解决了这个问题,该库单独接收每个鼠标的输入。
This was eventually solved by using a 3rd party library named "ManyMouse", which receives each mouse's input separately.