0

I am looking for a way to change the keyboard layout from within my Qt application. The application will run on a Linux kernel that doesn't support keyboard layout files, so Qt has to do everything concerning the mapping of the keyboard input.

In case of Qt for Embedded Linux I have found a good-looking solution here: Qt Embedded for Linux. Keyboard layout switching

But unfortunately the QKbdDriverFactory class is not available for any other Qt versions, according to the documentation here: http://qt-project.org/doc/qt-4.8/qkbddriverfactory.html I tried including it anyway (and astonishingly the class was there), but the compiler throws "undefined reference" errors whenever I invoke the create function.

Do I have to manually program huge QMap objects? Please tell me that there's a less tedious way. I don't want to believe that the qmap files can't be used outside of Qt for embedded Linux, because why would the kmap2qmap converter be available in practically any SDK if it's useless most of the time?

Alex

edit: Additional information: I am using Qt 4.7.4 (32 Bit) and QtCreator 2.4.1.
I work on Ubuntu 12.04, 64 Bit on a Virtual Machine.
The target system is a hardware with a specialized minimal Linux kernel, so trying to use Qt Embedded would be very difficult.
There is no Xcb server, no frame buffer plugin (edit2: But we do use a frame buffer) and I couldn't find out what DE or eglfs means.

Community
  • 1
  • 1
Alex
  • 1,198
  • 2
  • 12
  • 26
  • 1
    This question lacks important information. Are you using DE? Are you using X? Are you using eglfs? Are you using framebuffer plugin? Which version of Qt are you using? It is implied you're using Qt 4.8. Why don't you use Embedded then? – Vanuan Aug 19 '14 at 22:09
  • Ok, I added the information I was able to find out. Please note that I'm the same guy from the "Qt embedded" thread, so let's try not to get redundant. I just thought that it'd be better to create a new thread because it's a new question. – Alex Aug 20 '14 at 08:36
  • DE means desktop environment. So, it's embedded device, ok. I still don't understand how did you manage to run Desktop Qt version on a system without X11 or framebuffer or EGL. Linux graphics mode can be either X11, Framebuffer or EGL. Seems like it's not a conventional Linux system. Is it linux at all? You're on your own. Since there is no kbd module, you have to implement everything from scratch (see LFS project) or ask your kernel vendor to customize system to suit your needs – Vanuan Aug 22 '14 at 04:42
  • More information about EGL/X/Framebuffer support in Qt here: http://qt-project.org/forums/viewthread/24299 But it's for Qt5 – Vanuan Aug 22 '14 at 04:46
  • Maybe you're using Qt Embedded Android? – Vanuan Aug 22 '14 at 05:08
  • I misunderstood your question about frame buffer. My Qt doesn't have any such plugin, but after asking around now I know that we do use a frame buffer. I edited the opening post. – Alex Aug 28 '14 at 11:18

1 Answers1

1

Seems like you should implement your own keyboard support layer.

  1. You don't have dumpkeys program, so you can't generate keymap files on device. Use desktop version.
  2. Keycodes generated on desktop PC might be different from keycode generated by your device, so you should adapt them.
  3. After adapting keymap files you can write code to read these files.
  4. Having a map of KEY_CODE=>UTF8_CHARACTER you can intercept key events and translate them to input symbols, according to currently used keymap.
Vanuan
  • 31,770
  • 10
  • 98
  • 102
  • 1
    Thanks, I will keep that in mind, but for now we decided to try to switch to Qt Embedded. – Alex Aug 28 '14 at 11:20