get shift+numerical keys in qt using qkeyevent
Asked Answered
A

1

1

I am using QKeyEvent to get the Shift+numeric key, but it return me the ascii for "!" instead of "1" so my problem is, is there any method or techniques to get the actual numeric value's ascii instead of ascii of "!" (special character). I also followed this thread:

Get key char (value) from keycode with shift modifier

but it does not seems to help me to get rid from this problem. Thanks in advance.

Amphimixis answered 27/11, 2012 at 8:10 Comment(1)
Probably very late but I've just posted an answer in a similar question that may help you: https://mcmap.net/q/1550137/-get-original-key-as-though-without-shift-modifierQuarterstaff
G
0

I believe at least as of version 4.8 there is no standard method to get the numeric ascii value. You could try a brute force method similar to the thread you linked.

if (e->modifiers() & Qt::ShiftModifier) {
    switch(e->text()) {
        case '!': 
            trans_key = '1';
        break;
    }
}
Glob answered 27/11, 2012 at 9:4 Comment(3)
What about if the keys go change, as different countries has different keyboard keys?Amphimixis
I have no experience with other keyboard layouts, but one possible way could be to get the locale of the keyboard layout using QApplication::keyboardInputLocale(), which would return a QLocale object, and then handle it individually for each of your applications supported layout.Glob
Thanks ajith for all your time.Amphimixis

© 2022 - 2024 — McMap. All rights reserved.