简体   繁体   English

检测 keyPressEvent 上的插入符号 (^) 键 - Qt C++

[英]Detect the caret ( ^ ) key on keyPressEvent - Qt C++

I am currently developing an application in which I have implemented the keyPressEvent function.我目前正在开发一个应用程序,其中我已经实现了 keyPressEvent function。

I would like to detect when the user presses the ^ (caret, usually Shift + 6 on a US Keyboard) key for which I cannot identify it from the names of the keys provided by Qt ( Qt::Key_ ).我想检测用户何时按下^ (插入符号,通常是美国键盘上的Shift + 6 )键,我无法从 Qt ( Qt::Key_ )提供的键名中识别它。

Is the key available for detection?密钥是否可用于检测? If not how can I implement it's detection?如果不是,我该如何实现它的检测?


Just override the key event like this:只需像这样覆盖关键事件:
.h 。H

    public:
        MainWindow(QWidget *parent = nullptr);
        void keyPressEvent(QKeyEvent *e);
        ~MainWindow();


.cpp .cpp

void MainWindow::keyPressEvent(QKeyEvent *e)
{
    if(e->key() == Qt::Key_AsciiCircum)
    {
        qDebug() << "yep !";
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM