简体   繁体   English

如何通过Qt模拟按键事件并在QML的JavaScript中使用它?

[英]How simulate the key press event by Qt and use it in JavaScript of QML?

I write a program for embedded and my device have physics button and clickable icons above of this buttons. 我编写了一个嵌入式程序,我的设备具有物理按钮和该按钮上方的可单击图标。 User can press buttons or touch icons. 用户可以按下按钮或触摸图标。 Icons must generate keycode as buttons keycode. 图标必须生成键码作为按钮键码。 So icons must simulate keypress event and translate it to focused items. 因此,图标必须模拟按键事件并将其转换为重点项目。 I new in Qt and QML. 我是Qt和QML的新手。 The some tips here very little help me. 这里的一些提示对我没有什么帮助。

The simplest way would be to post a synthetic key event to the window that displays the QML scene. 最简单的方法是将合成键事件发布到显示QML场景的窗口中。 I have an example of this in another answer. 我在另一个答案中有一个例子

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM