get shift+numerical keys in qt using qkeyevent

两盒软妹~` 提交于 2019-12-12 05:39:06

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!