Detect the caret ( ^ ) key on keyPressEvent

343 Views Asked by At

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 its detection?

1

There are 1 best solutions below

0
On BEST ANSWER

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 !";
    }
}