I'm trying to catch keyPressEvents in my homegrown QWidget derived widget under Qt5 and X11. I have declared a protected function keyPressEvent
in my application and I receive as expected a QKeyEvent *event
. But when accessing the key pressed either by event->key()
or event->text()
the value return ignores the xkb mapping that is in effect! E.g. since I'm using the Dvorak keyboard layout the key 【Y】 maps to "F". So if I'm pressing the physical key 【Y】 in my application, I expect to get "f", but I don't; I get text()=="y"
and key()==89
. Contrast this with xev which as expected returns:
KeyPress event, serial 37, synthetic NO, window 0x2c00001,
root 0x90, subw 0x0, time 10101528, (102,85), root:(1562,106),
state 0x0, keycode 29 (keysym 0x66, f), same_screen YES,
XLookupString gives 1 bytes: (66) "f"
XmbLookupString gives 1 bytes: (66) "f"
XFilterEvent returns: False
Is this a bug in Qt5 or am I doing something wrong?
My keyboard mapping was loaded by doing xkbcomp ~/.xkbmap :0
.
Note that under Qt4 the program works as expected.