PDA

View Full Version : QShortcut SIGNAL must be of 0 arguments?



Wasabi
17th August 2010, 20:48
Is it possible for QShortcut (or some similar QObject) to send its code (Such as Qt::Key_G) as a SIGNAL to another widget's SLOT? It'd be nice if the other widget could have only one function to deal with all its keyboard events, as opposed to having one for each key.

Lykurg
17th August 2010, 21:26
Qt::Key is an enum which can be treated as an integer. So you simple can send an integer, or send the key directly:
Q_SIGNALS:
void myKeyPress(Qt::Key);
//...
Q_EMIT myKeyPress(Qt::Key_g);


EDIT: or use QKeyEvent as a wrapper.