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...??
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
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With