问题
How can I generate a KeyEvent?
I have to show functionality on Keys.onPressed & events generated from my virtual keyboard.
So can I fake generate key Events when my Virtual Keyboard events are generated?
I could only find how to sendKeyEvents to QML from Qt, but I want to signal it from QML.
回答1:
You can't directly in QML.
What you can do is expose to your QML Virtual keyboard a custom Qt object that emits key signals when you want (e.g. by calling a method YourCustomKeySignalGenerator::pressKey(YourKeyEnum pressedKey)
)
来源:https://stackoverflow.com/questions/13530784/generate-keyevent-from-qml