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.

Community
  • 1
  • 1
Ali Hassan
  • 607
  • 1
  • 11
  • 24
  • Probably very late but I've just posted an answer in a similar question that may help you: https://stackoverflow.com/a/55359130/1485885 – cbuchart Mar 26 '19 at 14:06

1 Answers1

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;
    }
}
Ajith
  • 613
  • 1
  • 15
  • 32
  • What about if the keys go change, as different countries has different keyboard keys? – Ali Hassan Nov 27 '12 at 13:24
  • 1
    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()](http://doc.qt.digia.com/qt/qapplication.html#keyboardInputLocale), which would return a QLocale object, and then handle it individually for each of your applications supported layout. – Ajith Nov 28 '12 at 03:14
  • Thanks ajith for all your time. – Ali Hassan Nov 28 '12 at 06:17