[Interest] Key Events in an offscreen QQuickWindow

Stefan Fabian stefan.fabian.dev at hotmail.com
Wed Jan 3 15:59:26 CET 2018


Hey,

I'm working on a library that overlays qt widgets and qml on top of a 3D scene by rendering the controls into an image and overlaying this image on the 3D scene.
This works quite well for QWidgets where I simply  do the event handling and especially the focus handling myself. No flashing cursor but I can live with that.
However, QML is not as easy. Mouse interaction works quite well because it suffices to pass the event to the QQuickWindow.
Keyboard interaction, however, is a lot harder because the elements don't get focus.
I've tried keeping track of the focused item myself but this proved harder than I thought if not impossible.
For instance, in a qml TextField control, the click might be on the text which will allow me to write text because the key events end up at the right element but if the user clicks next to the text, the element that I find is different and it won't work.
The problem here is probably that in normal cases clicks outside are handled by a mousearea that sets the focus to the editable element.

Any idea, how I can track the element that should have focus?
Or, how I could enable the QQuickWindow that is rendered offscreen using a QQuickRenderControl to handle focus by itself?
Qt version is 5.5.1

Best,
Stefan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20180103/b577c507/attachment.html>


More information about the Interest mailing list