How do I send Key Event from C++ to QML TextInput Item in Qt 5.2 ?
-
I'm sure you have QMLViewer object in C++. This is used for launching the QML file. Use this as destination object.
QtQuick2ControlsApplicationViewer w;
You can do
QApplication::postEvent(&w,new QKeyEvent(.....))
-
If this is the focused object, it will be sent to TextInput only.
-
If not we need to look at the issue. There may be other focused elements in the UI. What is the issue you are facing when you do this ?
-
if you have pointer to TextInput use the post event as I suggested
QApplication::postEvent(pointerToTextInput,new QKeyEvent(…..))
If you give the sample code it helps us to look/analyze if you have any issue.