Qt::Key to Keycode on x11



  • I try to find a way to map dynamically and reliably an arbitrary Qt::Key to the corresponding Keycode (as defined in X.h).

    In QxtGlobalShortcut this is done by translating the Qt::key to a X.h Keysym with @XStringToKeysym(QKeySequence(key).toString().toLatin1().data())@
    and looking up the keycode with XKeysymToKeycode(). Hower, getting the correct string as input for XStringToKeysym() is more or less coincidence and it doesnt work for many keys (like space, dot, comma, ...).

    I'm sure there must be a better way.

    Can anybody help? Thanks!



  • Nobody?

    I forgot to mention that the needed keycode is returned by QKeyEvent::nativeVirtualKey(). But it doesn't work for "artificially" created key events. Is there a way to create them with this data included?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.