Qt: KeyPress event

I start working in Qt and implement keypressevent. I want to handle the keys in such a way that if I press "A", then press "R" and press another key that I have to print.

How can this activity be handled in Qt ... ??

+5
source share
1 answer

You can get the key pressed with the function key(). A list of key codes can be found on this page of the document . So, if you want to use your Akey, you can either do

keyPressEvent( QKeyEvent * event )
{
    if( event->key() == Qt::Key_A )
    {
        // do your stuff here
    }
}

or directly use key code:

if( event->key() == 0x41 )
{
    // do your stuff here
}
+6
source

All Articles