简体   繁体   中英

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

I am currently developing an application in which I have implemented the 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_ ).

Is the key available for detection? If not how can I implement it's detection?


Just override the key event like this:
.h

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


.cpp

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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