Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Click event not catch by eventFilter

    General and Desktop
    2
    4
    245
    Loading More Posts
    • 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.
    • freddy311082
      freddy311082 last edited by

      Hi Guys

      I've been trying to fix a bug in our app which doesn't make any sense. I have a dialog which it's a color picker. There we have implemented an eyedropper which works (almost) fine and where we can pick any color around the screen. The problem we have happens in macOS.

      we are doing some tile:

      1. calling installEventFilter() in my eyedropper class
      2. calling grabMouse() to get all mouse events inside of it
      3. capture each mouse event in the eventFiler() method

      now, the problem I have is that the only mouse event which I cannot catch is the left click, and I know that because my eventFilter method looks like this:

      bool MyColorEyeDropper::eventFilter(QObject *object, QEvent *event)
      {
          if (event->type() == QEvent::MouseButtonPress)
          {
              QMouseEvent * mouseEvent = dynamic_cast<QMouseEvent*>(event);
              
              switch(mouseEvent->button())
              {
                  case Qt::LeftButton:
                      cout << "Left click !!" << endl;
                      break;
      
                  case Qt::RightButton:
                      cout << "Right click !!" << endl;
                      break;
      
                  default:
                      cout << "Something else !!" << endl;
                      break;
              }
          }
      
          return false;
      }
      

      and Left click !! never happens... do you have any idea where should I take a look? Because as far as I know, if I call grabMouse, all events will be catch by this widget till I call releaseMouse. Am I wrong?

      Regards

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        What version of Qt ?
        What version of macOS ?

        Can you provide a minimal compilable example that shows that behaviour ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 0
        • freddy311082
          freddy311082 last edited by

          @SGaist thanks for replying... I'm running our app on macOS 10.15.5 and we are using Qt 5.12.8.

          Regards

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            I don't have that macOS version at hand but if you provide a minimal compilable example, I can test it on my machine nonetheless.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply Reply Quote 1
            • First post
              Last post