Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
6.5.2
-
None
-
-
cd4000a97 (dev)
Description
I was happy to see that QShortcut in Qt6 is supposed to work with QWindow.
Sadly there does not seem to be any reaction at all if I try to attach a shortcut to any of my QWindows.
I added a code example below.
The QWidget works, whereas the QWindow doesn't.
This is what I see with QWidget when I press the "D" key:
Nothing is logged with QWindow when I press the "D" key.
#include <QApplication> #include <QWindow> #include <QWidget> #include <QShortcut> #include <QKeySequence> #include <QDebug> int main(int argc, char *argv[]) { QApplication a(argc, argv); QWindow w; // Does not work //QWidget w; // Does work QKeySequence key_sequence = QKeySequence::fromString("D"); QShortcut* shortcut = new QShortcut(key_sequence, &w); QObject::connect(shortcut, &QShortcut::activated, shortcut, [key_sequence]() { qDebug() << "Shortcut activated: " << key_sequence.toString(); }); QObject::connect(shortcut, &QShortcut::activatedAmbiguously, shortcut, [key_sequence]() { qDebug() << "Shortcut activated ambiguously: " << key_sequence.toString(); }); w.show(); return a.exec(); }