PDA

View Full Version : Passing synthetic keyboard events to the QQuickWindow



velorums
4th January 2016, 21:37
QQuickWindow is created from QQuickRenderControl and used as GUI overlay for an application. Input event loop is outside of Qt, so the events are sent manually through QCoreApplication::sendEvent.

Injecting mouse with QCoreApplication::instance()->sendEvent(quickWindow, event) works for push/release/move: can click buttons and select text in TextFields.

But I can't get the keyboard to work: it's not possible to edit the text in the TextField, cursor doesn't appear.

I've tried sending QFocusEvent, but it does nothing.

Also tried to setFocus and send QFocusEvent to the window and specific TextField. That got TextField into focus, but I'm not going to reimplement the focus rules.

How it's supposed to work?

anda_skoa
4th January 2016, 22:20
Well, usually events are not injected that way, e.g. the platform integration publishes them to the Qt event system which then distributes them.

But if you must tack this on like this then check if there is a focusObject: QGuiApplication::focusObject().

Cheers,
_

velorums
5th January 2016, 06:35
QGuiApplication::focusObject().


Well, if the QQuickWindow::activeFocusItem isn't getting it then there'll be nothing in QGuiApplication::focusObject() either.