Priority: P2: Important
Affects Version/s: 5.15.2, 6.2
Fix Version/s: 6.1.3
Component/s: Quick: Other
Commits:6dfed1ee9c8e03780b222a71f6b90fe2016d8994 (qt/qtdeclarative/dev) 4a9a3a52983652de2b4d91ff6ca25b90a0db930b (qt/qtdeclarative/6.1) a4646cb244963bf4b5667b53dcb25430f91dc814 (qt/qtdeclarative/6.2)
I am using a QQuickWindow, QQuickRenderControl and a QOffscreenSurface to render a Qml scene into an OpenGL framebuffer object.For this reason , I am using qt example Qt/Examples/Qt-5.15.2/quick/rendercontrol as a base with some minor modifications.
Since no window is actually created, it becomes necessary to artificially transfer mouse and keyboard events to QQuickWindow.There was already mousePressEvent example for mouseEvents on renderControl example which works fine that means I can send mouse events to qml.
Similarly , I tried to implement keyPressEvent and keyReleaseEvent by using QCoreApplication::sendEvent(m_quickWindow, e); function call but it does not send key events to qml even if I set force to true for a rectangle. When I debug the issue , I have observed that activeFocusItem is NULL on qquickwindow.cpp ==> deliverKeyEvent function.
After that , I put a mousearea inside rectangle and call forceActiveFocus() function for rectangle and then keyPressEvent are sent to qml succesfully.Also, If I put timer and call forceActiveFocus for rectangle on some interval it also works but If I try to call same forceActiveFocus() function on Component.onCompleted it is not sending any key events to qml.
So Do I have to call forceActiveFocus() to manage key sending for offscreen surface ? Also if I have to call forceActiveFocus() from qml , then is there any way to call it instead of timer or mousearea ?
I attached a simple application, Could you please check the issue ?