简体   繁体   English

QGraphicsItem中键按下事件

[英]QGraphicsItem middle mouse press event

I'm using Qt 5.3 on Linux. 我在Linux上使用Qt 5.3。 I have a QGraphicsScene and a QGraphicsItem. 我有一个QGraphicsScene和QGraphicsItem。 In my QGraphicsItem I implemented mousePressEvent, mouseReleaseEvent, mouseMoveEvent, to catch mouse events. 在我的QGraphicsItem中,我实现了mousePressEvent,mouseReleaseEvent,mouseMoveEvent来捕获鼠标事件。

It works fine, but I have to double click (with middle button) to get a middle button click event which is quite strange. 它工作正常,但是我必须双击(带有中间按钮)才能获得一个中间按钮单击事件,这很奇怪。 Also I discovered that I don't get any mouse move event when none of the buttons pressed. 我还发现当没有按键按下时,我没有任何鼠标移动事件。

I also implemented sceneEvent in my QGraphicsItem but that also misses the mouse move even unless a button is pressed, and only detect my middle button when I double click. 我还在QGraphicsItem中实现了sceneEvent,但即使没有按下按钮,也错过了鼠标的移动,并且仅在双击时才检测到我的中间按钮。 I also have a Wacom Intuos, it has (physical) right and middle buttons, the right button works correctly but I also have to double press the middle button to get any mouse press event. 我也有一个Wacom Intuos,它具有(物理)右按钮和中按钮,该右按钮可以正常工作,但是我还必须双击中按钮才能获得任何鼠标按下事件。

The middle buttons seems working in other applications, and xev reports the events correctly. 中间按钮在其他应用程序中似乎可以正常使用,并且xev可以正确报告事件。

Is there any way to to make the at least the middle mouse button work correctly? 有什么方法可以使至少鼠标中键正常工作?

要接收鼠标移动事件,您必须在窗口中启用鼠标跟踪

setMouseTracking(true);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM