Hi,
I wrote this:
but it doesn't work.Qt Code:
{ if(event->key() == Qt::Key_Escape) qApp->quit(); }To copy to clipboard, switch view to plain text mode
Where I'm wrong?
Thanks.
Hi,
I wrote this:
but it doesn't work.Qt Code:
{ if(event->key() == Qt::Key_Escape) qApp->quit(); }To copy to clipboard, switch view to plain text mode
Where I'm wrong?
Thanks.
Last edited by ale6111; 26th July 2010 at 14:47.
You can't access the QApplication object from there (and the QApplication object might have a different name)
One possible solution is to emit a signal when the Esc has been presed (example: closeExe(); or EscPresed();... ) and connect (in main.cpp), something like:
Qt Code:
To copy to clipboard, switch view to plain text mode
Last edited by Zlatomir; 26th July 2010 at 14:29.
Sine QApplication is a singleton class you can access it form everywhere with qApp. So one possibility is to use QWidget::keyPressEvent() and put your code there. Then it should work.
Yes it works, it was what I wanted to do, my mistake . Thanks.
Bookmarks