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. QWidgets stop responding to simulated mouse events
Forum Updated to NodeBB v4.3 + New Features

QWidgets stop responding to simulated mouse events

Scheduled Pinned Locked Moved Unsolved General and Desktop
15 Posts 3 Posters 1.6k Views 2 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.
  • jeremy_kJ jeremy_k

    I've seen similar behavior with a driver that failed to send touch release events. One of the widgets (or rather Item, using quick not widgets) was consuming all input while waiting for the release that never arrived. We diagnosed it by installing an event filter on the QGuiApplication instance.

    P Offline
    P Offline
    packetpirate
    wrote on last edited by
    #6

    @jeremy_k Could you give more details? What did the event filter do?

    jeremy_kJ 1 Reply Last reply
    0
    • SGaistS SGaist

      What happens if you use a new dialog ?

      P Offline
      P Offline
      packetpirate
      wrote on last edited by
      #7

      @SGaist Tried this and the behavior is the same.

      P 1 Reply Last reply
      0
      • P packetpirate

        @SGaist Tried this and the behavior is the same.

        P Offline
        P Offline
        packetpirate
        wrote on last edited by
        #8

        @packetpirate said in QWidgets stop responding to simulated mouse events:

        @SGaist Tried this and the behavior is the same.

        Correction. I had only commented out where we set it to false. Setting it explicitly to true results in the dialog never coming back and the process hanging there.

        1 Reply Last reply
        0
        • P packetpirate

          @jeremy_k Could you give more details? What did the event filter do?

          jeremy_kJ Offline
          jeremy_kJ Offline
          jeremy_k
          wrote on last edited by jeremy_k
          #9

          @packetpirate said in QWidgets stop responding to simulated mouse events:

          @jeremy_k Could you give more details? What did the event filter do?

          I find event filters to be a useful debugging aid, to see what events are delivered, to which recipient, and when.

          struct Object : public QObject {
              bool eventFilter(QObject *watched, QEvent *event) override {
                  qDebug() << watched << event->type();
                  return QObject::eventFilter(watched, event);
              }
          };
          
          int main() {
              QApplication app;
              Object filter;
              app.installEventFilter(&filter);
              return app.exec();
          }
          

          Asking a question about code? http://eel.is/iso-c++/testcase/

          P 1 Reply Last reply
          1
          • jeremy_kJ jeremy_k

            @packetpirate said in QWidgets stop responding to simulated mouse events:

            @jeremy_k Could you give more details? What did the event filter do?

            I find event filters to be a useful debugging aid, to see what events are delivered, to which recipient, and when.

            struct Object : public QObject {
                bool eventFilter(QObject *watched, QEvent *event) override {
                    qDebug() << watched << event->type();
                    return QObject::eventFilter(watched, event);
                }
            };
            
            int main() {
                QApplication app;
                Object filter;
                app.installEventFilter(&filter);
                return app.exec();
            }
            
            P Offline
            P Offline
            packetpirate
            wrote on last edited by packetpirate
            #10

            @jeremy_k Ah, I see. This won't really help me though since the events aren't delivered to the dialog. They're delivered straight to the widget. When I synthesize the mouse events from the touchscreen data, I get the coordinates and use the QApplication::widgetAt() method to identify the widget underneath the touch point, and then call QApplication::postEvent() to send the mouse event directly to that widget. The widgets are part of the dialog and defined in the UI file, so they don't have their own class where I can define an eventFilter for them.

            jeremy_kJ 1 Reply Last reply
            0
            • P packetpirate

              @jeremy_k Ah, I see. This won't really help me though since the events aren't delivered to the dialog. They're delivered straight to the widget. When I synthesize the mouse events from the touchscreen data, I get the coordinates and use the QApplication::widgetAt() method to identify the widget underneath the touch point, and then call QApplication::postEvent() to send the mouse event directly to that widget. The widgets are part of the dialog and defined in the UI file, so they don't have their own class where I can define an eventFilter for them.

              jeremy_kJ Offline
              jeremy_kJ Offline
              jeremy_k
              wrote on last edited by
              #11

              @packetpirate said in QWidgets stop responding to simulated mouse events:

              @jeremy_k Ah, I see. This won't really help me though since the events aren't delivered to the dialog.

              That's why the example installs the event filter on the QApplication. This allows it to see events delivered to all QObject instances.

              Asking a question about code? http://eel.is/iso-c++/testcase/

              P 1 Reply Last reply
              1
              • jeremy_kJ jeremy_k

                @packetpirate said in QWidgets stop responding to simulated mouse events:

                @jeremy_k Ah, I see. This won't really help me though since the events aren't delivered to the dialog.

                That's why the example installs the event filter on the QApplication. This allows it to see events delivered to all QObject instances.

                P Offline
                P Offline
                packetpirate
                wrote on last edited by
                #12

                @jeremy_k Alright, so this did finally help me get some new information, though I'm not sure what it means yet. I added debug messages both where I created the mouse events for press and release, and installed an event filter that does what you showed, but only prints a debug message if it's a mouse press or release event.

                The messages show properly on both sides no matter what, so the buttons ARE receiving the mouse events. But I also added debug messages where I manually set focus on certain types of widgets, such as QLineEdit and QComboBox which are present on the login form. I have a message before and after calling setFocus() on them to verify the focus gets set.

                Before the failed login, the focus is properly set when I touch the password field. But after a failed login, when I touch the password field, my debug messages indicate even after manually setting focus on the widget, it doesn't have focus. So even though the on-screen keyboard buttons are receiving the events, there's nowhere to output the text I'm typing.

                But there's one specific QComboBox on the login form that after I press it and select something, suddenly pressing the password field will properly set the focus again and allow me to type.

                What's going on here?

                1 Reply Last reply
                0
                • P Offline
                  P Offline
                  packetpirate
                  wrote on last edited by
                  #13

                  After playing around some more, there is some new information that is less specific to our application.

                  It seems that after the failed login, even the mouse can't give focus to QLineEdit fields. The physical keyboard can still type in these fields, but the on-screen keyboard cannot. If we login properly and then logout, the fields work properly again, and they also start working again after clicking or touching the QComboBox and selecting a different item.

                  I suspect this may be a bug specific to the OS (window manager) or the version of Qt we're using.

                  Are there any known bugs like this in RedHat 8.4 or Qt 5.15? We have been using this same touchscreen driver and application code in previous releases that were on Scientific Linux 6.4 and did not have this issue, which is why I believe the problem lies in Qt or RedHat.

                  1 Reply Last reply
                  0
                  • jeremy_kJ Offline
                    jeremy_kJ Offline
                    jeremy_k
                    wrote on last edited by
                    #14

                    I wonder if there's something grabbing the keyboard, mouse, or otherwise changing focus unexpectedly. QApplication::focusChanged() is good for catching focus changes when they happen.

                    The QEvent::Focus(In|Out|AboutToChange) and QEvent::Grab(Mouse|Keyboard) events can be picked up via the event filter.

                    Asking a question about code? http://eel.is/iso-c++/testcase/

                    P 1 Reply Last reply
                    0
                    • jeremy_kJ jeremy_k

                      I wonder if there's something grabbing the keyboard, mouse, or otherwise changing focus unexpectedly. QApplication::focusChanged() is good for catching focus changes when they happen.

                      The QEvent::Focus(In|Out|AboutToChange) and QEvent::Grab(Mouse|Keyboard) events can be picked up via the event filter.

                      P Offline
                      P Offline
                      packetpirate
                      wrote on last edited by
                      #15

                      @jeremy_k After adding those events to the event filter, I don't see anything suspicious grabbing the mouse or keyboard. I don't get a single grab event anywhere. Plenty of focus changing, but none that look out of place.

                      1 Reply Last reply
                      0

                      • Login

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