Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if [Shift + Tab] is being pressed in QT

Tags:

c++

qt

qkeyevent

How would one check if the SHIFT key is held and the TAB key is pressed with a QKeyEvent?

I've tried using:

(event->key() == Qt::Key_Tab && event->modifiers() == Qt::ShiftModifier)

However, the event->key() is not equal to Qt::Key_Tab whenever the shift key is held down.

like image 317
Griffort Avatar asked Jan 28 '23 16:01

Griffort


1 Answers

If event->key() is printed in hexadecimal format:

qDebug()<<QString("key: 0x%1").arg(event->key(), 8, 16, QChar('0'));

you get what: "key: 0x01000002" then checking in the docs and you see that the key is:

Qt::Key_Backtab 0x01000002

So you have to use that key:

if(event->key() == Qt::Key_Backtab)
like image 141
eyllanesc Avatar answered Feb 05 '23 05:02

eyllanesc