Solved mouseMoveEvent() does not give information about the button that was pressed
-
Hi.
I have overloaded several functions to handle mouse events
void mousePressEvent(QMouseEvent *event) override; void mouseReleaseEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override;
In the first two functions, when using
event->button()
I get the correct button.However, in the case of
mouseMoveEvent()
, I getQt::NoButton
.
For me, this event only occurs when I move the mouse with the mouse button held down.
Why is this happening? -
Hi,
No it does not, you might have enabled mouse tracking on your widget and therefore your will get this event without or without button pressed.
-
@SGaist No.
I realized that this is normal, the documentation for thebutton()
method says: "Note that the returned value is always Qt::NoButton for mouse move events."
Thanks for answer. -
Indeed it is in the documentation. I thought you were questioning that so I was answering to this particular sentence:
@mrjbom said in mouseMoveEvent() does not give information about the button that was pressed:For me, this event only occurs when I move the mouse with the mouse button held down.