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

Regression: Keyboard input unusable with redirected Qt Quick scenes (QQuickRenderControl)



    • 73b80e1b4 (dev), 6f4a643d1 (6.6), c72934028 (6.5)


      Take the rendercontrol_opengl example.

      This claims

      In addition, basic input event forwarding is also demonstrated. When holding down the left mouse button, the background Rectangle color is altered via QML bindings. Similarly, holding down a key on the keyboard changes the color as well. This proves that the "fake" events sent from the application (generated based on events from the on-screen QWindow) are forwarded and processed within the Qt Quick scene.

      Clicking the mouse changes the Quick scene's (that's then shown on the cube) background gradient. Pressing a key should change it in a different way. But the latter is broken in Qt 6. In Qt 5 this used to work (since it's even documented for the example).

      Relevant bits in the QML source code:

          gradient: Gradient {
              GradientStop { position: 0; color: mouse.pressed ? "lightsteelblue" : (root.keyDown ? "blue" : "steelblue") }
              GradientStop { position: 1; color: "black" }
          Keys.onPressed: keyDown = true
          Keys.onReleased: keyDown = false

      In the C++ code:

      void WindowSingleThreaded::keyPressEvent(QKeyEvent *e)
          QCoreApplication::sendEvent(m_quickWindow, e);
      void WindowSingleThreaded::keyReleaseEvent(QKeyEvent *e)
          QCoreApplication::sendEvent(m_quickWindow, e);

      where m_quickWindow is an invisible QQuickWindow.

      This stopped working at some point, sending the event is now futile since the delivery agent things there is no focus item, and it is not possible to change it (adding focus: true has no effect).

      We have the same problem with the qtquick3dxr module and some new test applications that all use QQuickWindow rendering redirected into a texture. Keyboard input is impossible to have for this apps, it seems.


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



            lagocs Laszlo Agocs
            lagocs Laszlo Agocs
            0 Vote for this issue
            2 Start watching this issue



              Gerrit Reviews

                There are no open Gerrit changes