1
votes

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.

1
If that's reproducible with the latest Qt, I'd say: submit a bug report.peppe
There appears to be bug report already: bugreports.qt-project.org/browse/QTBUG-32322 . Unfortunately there is no fix accepted yet. :-(Dov Grobgeld

1 Answers

2
votes

As it has been said, this was a bug in Qt.

It has been worked on in these two changesets:

The latter was merged and is expected to arrive in Qt 5.3, which is scheduled for 7th May 2014.