Generate KeyEvent from QML

那年仲夏 提交于 2020-01-03 18:28:11

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!