Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Missing keyEvents for Qt::Key_Alt



  • Ubuntu - Gnome - X11 - Qt 5.12.8

    I am logging all keys pressed using

    keyPressEvent(QKeyEvent *event)

    and

    keyReleaseEvent(QKeyEvent *event)

    It works for all keys except Qt::Key_Alt (ok the windows key gives nothing but this is expected)

    Imagine I press and release twice

    All keys will give me

    Press - Event
    Release - Event
    Press - Event
    Release - Event

    for Alt I get

    Press - Event
    Release - No event triggered
    Press - No event triggered
    Release - Event

    Why is that? Has it to do with GNOME?



  • Yes.. GNOME is an abomination....and the underlying X11 system receives the alt scancode but "something" is mofidying the behaviour.

    install and use xev to see what the native X11 system is generating.



  • I tried xev and the events reported for Alt and AltGr are similar, one for press and one for release.
    From this I can only imagine Qt is doing something to filter it.

    KeyPress event, serial 37, synthetic NO, window 0x5200001,
    root 0x143, subw 0x0, time 48633066, (480,-15), root:(833,969),
    state 0x10, keycode 108 (keysym 0xfe03, ISO_Level3_Shift), same_screen YES,
    XKeysymToKeycode returns keycode: 92
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

    KeyRelease event, serial 37, synthetic NO, window 0x5200001,
    root 0x143, subw 0x0, time 48633218, (480,-15), root:(833,969),
    state 0x90, keycode 108 (keysym 0xfe03, ISO_Level3_Shift), same_screen YES,
    XKeysymToKeycode returns keycode: 92
    XLookupString gives 0 bytes:
    XFilterEvent returns: False

    KeyPress event, serial 37, synthetic NO, window 0x5200001,
    root 0x143, subw 0x0, time 48634514, (480,-15), root:(833,969),
    state 0x10, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

    KeyRelease event, serial 37, synthetic NO, window 0x5200001,
    root 0x143, subw 0x0, time 48634650, (480,-15), root:(833,969),
    state 0x18, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False



  • Don't assume it is Qt. Many modern abonimation desktop environments layer that stuff to hide it from the Luser, because we all know low level is dangerous and folks should not be trusted with anything but point-n-click...but I digres. You may/probably have a keyboard management layer that is remapping keysyms.

    Now that you understand xev, you should learn about xmodmap.
    http://xahlee.info/linux/linux_xmodmap_tutorial.html


Log in to reply