qt setting QWSServer keymap from code

青春壹個敷衍的年華 提交于 2019-12-25 02:18:09

问题


I need to a keymap for my embedded QWSServer application.

Using environmental variables like this

QWS_KEYBOARD="TTY:keymap=/german_keyboard.qmap"
export QWS_KEYBOARD

works, but isn't optimal for me.

I tried to set it from code using

QWSServer* wsServer = QWSServer::instance();
QWSKeyboardHandler * kh = QKbdDriverFactory::create("TTY", "keymap=/german_keymap.qmap");
wsServer->setKeyboardHandler(kh);

as mentioned here.

However, it is not working. Any ideas how to fix it?


回答1:


It actually looks like you couldn't do it. According to this manual page you can only set the driver and device for a keyboard handler, but no additional options like keymap. In this arcticle about the keymap thing only the environment variable way ist mentioned, too.

Because of this, the answer here seems to be wrong.

Beware: According to this answer, Qt5 doesn't have QWS and all QWS-related APIs have been removed.




回答2:


You can try:

QWSServer::instance()->closeKeyboard();
QWSKeyboardHandler * kh = QKbdDriverFactory::create("TTY", "keymap=/german_keymap.qmap");

It works for me, but only the first time, if I want to change the layout a second time, the closeKeyboard() will crash, as it's trying to delete the driver defined by QWS_KEYBOARD, and it has already been deleted the first time.



来源:https://stackoverflow.com/questions/13239590/qt-setting-qwsserver-keymap-from-code

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