PDA

View Full Version : shortcut from main



ChasW
2nd February 2007, 20:31
Is it possible to create a shortcut or connection from main() that quits the app using a keypress? i.e. not from within a widget

I realize qApp->quit() is the call I need, but Im not sure how to connect that to a keypress shortcut that doesnt come from a button click or other type of SIGNAL.

.. and when I do something like this:

(void) new QShortcut(Qt::Key_Escape, &app, (QApplication::quit()));

i get invalid use of void expression

Thank you,
ChasW

jpn
2nd February 2007, 21:08
QShortcut constructor takes a QWidget* and you are also missing the SLOT() macro:


new QShortcut(Qt::Key_Escape, anyWidget, SLOT(close()));