Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
6.5, 6.6, 6.7
-
None
-
73b80e1b4 (dev), 6f4a643d1 (6.6), c72934028 (6.5)
Description
Take the rendercontrol_opengl example.
https://doc.qt.io/qt-6/qtquick-rendercontrol-rendercontrol-opengl-example.html
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.