Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-48343

QQuickWidget cannot intercept QKeyEvents

XMLWordPrintable

    • 0dbc575c1a8359534761167a5f5f1e29abedd51d

      Fixing QTBUG-42677 broke support for intercepting keyboard events at the QQuickWidget level, as a side-effect also breaking recording of text typing for Squish GUI Tester. The only objects "seeing" key press/release events since Qt 5.4.1 are the QWidgetWindow and the focused QQuickItem.

      Attached is a small QTest example which tries to reproduce the problem.

      • Building with Qt 5.4.0 passes both tests.
      • Building with Qt 5.5.0 fails the QQuickWidget test.

      For completeness, here's a dump of events seen when intercepting all events going through qApp notify:

      Qt 5.4.0:

      notify: receiver{ objectName:"quickwidgetscenarioWindow" className:QWidgetWindow } event{ type:KeyPress spontaneous:1 isAccepted:1 modifiers:0x0 timestamp:1630681080 key:0x54 text:"t" }
      notify: receiver{ objectName:"quickwidgetscenario" className:QQuickWidget } event{ type:KeyPress spontaneous:1 isAccepted:1 modifiers:0x0 timestamp:1630681080 key:0x54 text:"t" }
      notify: receiver{ className:QQuickWindow } event{ type:KeyPress spontaneous:0 isAccepted:1 modifiers:0x0 timestamp:1630681080 key:0x54 text:"t" }
      notify: receiver{ objectName:"inputOne_input" className:QQuickTextInput } event{ type:KeyPress spontaneous:0 isAccepted:1 modifiers:0x0 timestamp:1630681080 key:0x54 text:"t" }
      

      Qt 5.5.0:

      notify: receiver{ objectName:"quickwidgetscenarioWindow" className:QWidgetWindow } event{ type:KeyPress spontaneous:1 isAccepted:1 modifiers:0x0 timestamp:1630675019 key:0x54 text:"t" }
      notify: receiver{ objectName:"inputOne_input" className:QQuickTextInput } event{ type:KeyPress spontaneous:1 isAccepted:1 modifiers:0x0 timestamp:1630675019 key:0x54 text:"t" }
      

      IMHO QTBUG-42677 could be fixed differently: Forwarding to the focused QQuickItem could rather be done in QQuickWidget::keyPressEvent() and QQuickWidget::keyReleaseEvent(). That way interested parties (custom subclasses, Squish) can still "see" those key events on the QQuickWidget.

      I can come up with a patch implementing the above if this is an acceptable way to keep input methods working.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            tvete Paul Olav Tvete
            metz Stefan Gehn (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes