Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. mouseReleaseEvent not called only with Qt::RightButton

mouseReleaseEvent not called only with Qt::RightButton

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 619 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • UlysseU Offline
    UlysseU Offline
    Ulysse
    wrote on last edited by Ulysse
    #1

    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

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

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

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      UlysseU 1 Reply Last reply
      2
      • Christian EhrlicherC Christian Ehrlicher

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

        UlysseU Offline
        UlysseU Offline
        Ulysse
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          The you have to minimize your program until it works.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          UlysseU 1 Reply Last reply
          0
          • Christian EhrlicherC Christian Ehrlicher

            The you have to minimize your program until it works.

            UlysseU Offline
            UlysseU Offline
            Ulysse
            wrote on last edited by
            #5

            @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.

            1 Reply Last reply
            2

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved