Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.15, 6.5, 6.6, 6.7
-
None
Description
Trying to handle it like that:
#include <QApplication> #include <QWidget> #include <QLabel> #include <QVBoxLayout> #include <QtEvents> class Widget : public QWidget { public: Widget() : _layout(this) { _layout.addWidget(&_label); } protected: void keyPressEvent(QKeyEvent *e) override { const auto modifiers = e->modifiers() & ~(Qt::KeypadModifier | Qt::GroupSwitchModifier); const auto matches = [&](const QKeySequence &sequence) { const auto events = QKeySequence(modifiers | e->key()); return sequence.matches(events) == QKeySequence::ExactMatch; }; if (matches(QKeySequence("ctrl+shift+."))) { _label.setText("ctrl+shift+."); } } void keyReleaseEvent(QKeyEvent *e) override { _label.setText({}); } private: QVBoxLayout _layout; QLabel _label; }; int main(int argc, char *argv[]) { QApplication app(argc, argv); Widget widget; widget.show(); return app.exec(); }
Doesn't seem to work on Windows with Qt 5.15 (haven't tried later versions) and on Linux (both X11 and Wayland) with Qt 6.5, 6.6, 6.7.
Although, this seems to work on macOS with Qt 6.2.
(Personally I have done only testing on Linux, the feedback from Windows and macOS I got from other persons)