You were right, it doesn't work. I made it work this way:
#include <QApplication>
#include <QWidget>
#include <QAction>
#include <QKeySequence>
int main(int argc, char **argv){
act.connect(&act, SIGNAL(triggered()), &w, SLOT(close()));
w.addAction(&act); // this here does the trick
w.show();
return app.exec();
}
#include <QApplication>
#include <QWidget>
#include <QAction>
#include <QKeySequence>
int main(int argc, char **argv){
QApplication app(argc, argv);
QWidget w;
QAction act("quit", &w);
act.connect(&act, SIGNAL(triggered()), &w, SLOT(close()));
act.setShortcut(QKeySequence(Qt::Key_Escape));
w.addAction(&act); // this here does the trick
w.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks