问题
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.
回答1:
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;
}
}
来源:https://stackoverflow.com/questions/13579815/get-shiftnumerical-keys-in-qt-using-qkeyevent