Solved mouseReleaseEvent not called only with Qt::RightButton
-
Solution
In my case, themouseReleaseEvent
was caught by another widget becausemousePressEvent
withQt::RightButton
shows a menu at the clic position
Hi
I have a Canvas class that looks like this :class Canvas : public QOpenGLWidget { // [...] protected : void mouseReleaseEvent(QMouseEvent* e) override { std::cout << "mouseRelease called "; if (e->button() == Qt::RightButton) { std::cout << "with right button" << std::endl; } else if (e->button() == Qt::LeftButton) { std::cout << "with left button" << std::endl; } QOpenGLWidget::mouseReleaseEvent(e); } // [...] };
Now when I
- left click into my canvas i get :
mouseRelease called with left button
- right click into my canvas i get nothing (the method is not called)
I tried with both my laptop pad and my mouse, both give the same result.
I could not reproduce the bug in a minimal example and his bug does not occur when i compile my project with Qt 5.6
Any ideas ?
Regards
- left click into my canvas i get :
-
You should call the base class impl of mousePress/ReleaseEvent() functions.
-
@Christian-Ehrlicher Right thank you
It does not solve the problem though -
The you have to minimize your program until it works.
-
@Christian-Ehrlicher The me knows these things thank you
I have found the issue :
On mousePressed with RightButton, a QMenu is shown. I am afraid that the mouseRelease was then caught by the menu instead of my canvas.