Details
-
Bug
-
Resolution: Unresolved
-
P4: Low
-
None
-
5.0.0 RC 1, 5.0.0
-
None
-
Windows 7
Description
Say you have a QMainWindow subclass with a reimplemented keyPressEvent and keyReleaseEvent. If the window has an action with a QKeySequence shortcut, and you type that shortcut, keyPressEvent is not called. This is to be expected, since the QAction handles the event. However, keyReleaseEvent is called. This can result in unwanted keyReleaseEvents.
#include <QtGui> #include <QtWidgets> class MainWindow : public QMainWindow { protected: void keyPressEvent(QKeyEvent *) {qDebug() << "pressed";} void keyReleaseEvent(QKeyEvent *) {qDebug() << "released";} }; int main(int argc, char *argv[]) { QApplication app(argc, argv); MainWindow window; QAction action(QString("Copy"), &window); action.setShortcut(QKeySequence::Copy); window.menuBar()->addAction(&action); window.show(); return app.exec(); }