Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt : KeyPress event [closed]

Tags:

c++

qt

i am starter in Qt and was implementing keypressevent. I want to handle keys in such a way that if 'A' is pressed it shoud print 'R' and press of other key i should print.

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

like image 898
user1693462 Avatar asked Sep 24 '12 04:09

user1693462


1 Answers

You can get the key that was pressed by using a key() function. The list of codes for the keys can be found at this doc page. So, if you want your A key, you can either do

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

or use the key code directly:

if( event->key() == 0x41 )
{
    // do your stuff here
}
like image 158
SingerOfTheFall Avatar answered Nov 01 '22 06:11

SingerOfTheFall