Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

mouseReleaseEvent not called only with Qt::RightButton



  • Solution
    In my case, the mouseReleaseEvent was caught by another widget because mousePressEvent with Qt::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


  • Qt Champions 2019

    You should call the base class impl of mousePress/ReleaseEvent() functions.



  • @Christian-Ehrlicher Right thank you
    It does not solve the problem though


  • Qt Champions 2019

    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.


Log in to reply