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. Click event not catch by eventFilter
QtWS25 Last Chance

Click event not catch by eventFilter

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 561 Views
  • 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.
  • freddy311082F Offline
    freddy311082F Offline
    freddy311082
    wrote on last edited by
    #1

    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
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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
      0
      • freddy311082F Offline
        freddy311082F Offline
        freddy311082
        wrote on last edited by
        #3

        @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
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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
          1

          • Login

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