Important: Please read the Qt Code of Conduct -

Overriden event function and strange Alt+= key behaviour

  • I am handling QEvent::KeyPress events in class derived from QLineEdit and everything would be good if not one key.
    Alt+= is acting something like compose key in my system. I can insert ȩḑçņ characters and to be honest i have no idea why.
    This is how it looks inside event(QEvent* e):

    [ 01:50:17 ]: QKeyEvent(KeyRelease, 100125b, 40000000, ""¸"", false, 2)  // for alt+=
    [ 01:51:18 ]: QKeyEvent(KeyRelease, 100125c, 42000000, ""˛"", false, 2)  // for alt+shift+=

    There are no QEvent::KeyPress events! Besides of that it is somehow inserting ¸¸¸¸¸or ˛˛˛˛ when i hold these keystrokes. I don't want that. That's nasty.

    My problem is I really want to handle this keystroke and get nativeScanCode() with '='.
    Xev is displaying this as

    KeyPress event, serial 40, synthetic NO, window 0x5800001,
        root 0x270, subw 0x0, time 16442476, (-857,169), root:(427,799),
        state 0x90, keycode 21 (keysym 0xfe5b, dead_cedilla), same_screen YES,
        XLookupString gives 2 bytes: (c2 b8) "¸"
        XmbLookupString gives 0 bytes: 
        XFilterEvent returns: True

    Is this XFilterEvent my obstacle here? What can I do?

  • Lifetime Qt Champion


    With which version of Qt are you experiencing this ?

  • @SGaist This is 4.8 but i'm moving code to latest 5 version soon.
    It just seems like Qt somehow doesn't handle this event which xev is able to properly detect.

  • Lifetime Qt Champion

    IIRC Qt 5.5.0 has a bug handling certain key combination which should be fixed for 5.5.1 If you can, try with this one (you may have to built it by hand though)

Log in to reply