Qt中的键盘输入 [英] Keyboard input in Qt

查看:1412
本文介绍了Qt中的键盘输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究在嵌入式Linux上运行的Qt应用程序.我对Qt业务很陌生,因为一个月前才刚刚开始,所以请理解我不是面向对象 ...:P

I am working on a Qt application running on embedded Linux. I am pretty new to this Qt business since I have just started it a month back, so understand that I'm not that object-oriented ... :P

我在运行Linux的目标上运行Qt应用程序. Qt文档 http://doc.qt.io/archives/qt-4.7/qt-embedded-pointer.html 说,我们必须通过导出某些变量来启用触摸屏,USB键盘,小键盘等.即

I have the Qt applications running on my target running Linux. The Qt documentation http://doc.qt.io/archives/qt-4.7/qt-embedded-pointer.html says that we have to enable touchscreen, USB keyboard, keypad, etc. by exporting certain variables. Namely,

export QWS_MOUSE_PROTO=tslib:/dev/input/event1
export QWS_KEYBOARD="linuxinput:/dev/input/event0 usb:/dev/input/event2"

好吧,您可以猜到,第一行将QT中的鼠标设备设置为触摸屏. "tslib"是触摸屏库,"event1"是代表触摸屏的节点.同样,第二行用于板载键盘(event0)和USB键盘(event2).

well, as you can guess, first line sets the mouse device in QT as touchscreen. "tslib" is the touchscreen library, and the "event1" is the node representing the touchscreen. Similarly, second line is for on-board keypad (event0), and USB keyboard (event2).

现在,触摸屏可以很好地工作了.但是问题出在哪一个键盘上.如果我不导出第二个变量,即 QWS_KEYBOARD ,则该应用程序可以正常运行.但是,如果我确实导出了第二个变量,则应用程序在启动后会立即进入停止状态(SIGSTOP).从ps输出可以明显看出这一点.我无法使其与SIGCONT一起使用.

Now, the touchscreen work very well. But the problem is with either keyboard. If I do not export the second variable, namely QWS_KEYBOARD , then the application runs fine. But if I do export the second variable, the application goes into stopped state (SIGSTOP) as soon as it is launched. This is evident from ps output. I can not make it work with SIGCONT.

我将尝试从源头重新配置Qt.任何想法都欢迎.

I am going to try and reconfigure Qt from source. Any thoughts are welcome.

推荐答案

不敢相信,但是将QWS_KEYBOARD变量设置为null可以解决此问题. 在Qt开发人员常见问题解答中找到它 http://developer.qt.nokia.com/faq/answer/why_doesnt_my_keyboard_work_after_i_have_done_an_export_qws_keyboard_dev_tt

Can not believe this but setting the QWS_KEYBOARD variable as null solved the problem. Found it in the Qt developer FAQ http://developer.qt.nokia.com/faq/answer/why_doesnt_my_keyboard_work_after_i_have_done_an_export_qws_keyboard_dev_tt

export QWS_KEYBOARD=""

嗯,它不能完全解决问题,因为我仍然必须将本地键盘与USB键盘一起使用.

Well, it did not completely solve the problem since I still have to include the native keypad along with the USB keyboard.

无论如何,我可以使用箭头/TAB键移动到字段.文字输入效果很好.虽然CAPS-LOCK和NUM-LOCK似乎不起作用. SHIFT起作用.我可以通过Ctrl + Alt + Bkspce终止应用程序.因此,暂时来说,我至少可以输入文本.

Anyway, I am able to move to fields using the arrow/TAB keys. Text input works well. Although CAPS-LOCK and NUM-LOCK do not seem to work. SHIFT works. I am able to terminate the application by Ctrl+Alt+Bkspce. So, for the time being, I am able to input text at least.

如果有任何改进,将发布.

Will post if any improvements.

这篇关于Qt中的键盘输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆