Qt Embedded for Linux. Keyboard switch

I am developing an application with Qt Embedded and running it in linux framebuffer. I need a way to enter non-American characters. Is it possible to change the keyboard layout using Qt?

I tried to run it on Qt / X11. Switching and typing is fine there. But when I compile it with Qt / Embedded and run it in framebuffer, I cannot change the layout.

I searched the documentation and found nothing about switching layouts.

I think this has something to do with the qt keyboard driver, as stated in the documentation . It seems that I should develop my own keyboard driver. But I use a standard keyboard, and I think there should be a standard way to change the input language?

What would you suggest?

By the way, I am using version 4.5. Perhaps 4.6 has something to solve this problem?

The exact problem is here:

http://lists.trolltech.com/pipermail/qt-embedded-interest/2008-August/000034.html

http://lists.trolltech.com/qt-interest/2004-02/msg00570.html

+4
source share
3 answers

Version 4.6 provides keyboard layout support . Decision:

  • create kmap file:

    ckbcomp -layout xx> xx.kmap

  • convert kmap to qmap

    kmap2qmap xx.kmap xx.qmap

  • load a key card either using

    • with the QWS_KEYBOARD environment variable:

      QWS_KEYBOARD = "TTY: Layout = xx.qmap"

    • or dynamically load the layout:

      QWSKeyboardHandler * currentKeyboardHandler = QKbdDriverFactory::create("TTY", "keymap=foo.qmap"); 

      Make sure you delete the created handler when creating a new one:

       delete currentKeyboardHandler; currentKeyboardHandler = QKbdDriverFactory::create("TTY", "keymap=bar.qmap"); 

Qt seems to be for the built-in linux superseeded Project Lighthouse . Not sure though, if it's ready for production, and I don't know how it handles switching keyboard layouts.

Update

Qt5 does not have QWS, and all APIs associated with QWS are removed. So you will need a third party solution. Or write a plugin for QPA .

+7
source

I need a way to enter non-US characters

You can change qmap, but even in Qt 4.8.0 there is no way to switch between the USA and Russia (for example). You need to fix kmap2qmap (add support for AltGr_Lock), qkbd_qws.cpp (change testmods to match the state of AltGr_Lock). Nobody seems to be using QtEmbedded with a keyboard. Or everyone keeps the final patches in a secret place.

+3
source

I can not comment, so this is the answer to

You need to fix kmap2qmap (add AltGr_Lock support), qkbd_qws.cpp (change testmods to match AltGr_Lock state).

This simple patch for qkbd_qws.cpp allows you to switch between languages ​​using the CapsLock button.

 523,526c523,524 < //if (d->m_locks[0] /*CapsLock*/ && (m->flags & QWSKeyboard::IsLetter)) < // testmods ^= QWSKeyboard::ModShift; < if (d->m_locks[0] /*CapsLock*/) < testmods ^= QWSKeyboard::ModAltGr; --- > if (d->m_locks[0] /*CapsLock*/ && (m->flags & QWSKeyboard::IsLetter)) > testmods ^= QWSKeyboard::ModShift; 
0
source

Source: https://habr.com/ru/post/1307366/


All Articles