how to ignore dedicate event ( press alt + space)
-
in windows, when we press alt + space, system will show a menu of the active window. but i do dont want it. tell me if i can ignore it. Thanks~
@Tian__12 You can override https://doc.qt.io/qt-5/qwidget.html#keyPressEvent in your main window
-
@Tian__12 You can override https://doc.qt.io/qt-5/qwidget.html#keyPressEvent in your main window
@jsulm Thanks for ur help.
but it doesn't work.i try to override keypressevent, and install eventFilter. both does not work. even more, when i press alt + space, qt only post one keyEvent(alt pressdown).
void keyPressEvent(QKeyEvent *keyEvent) override { fout << "keyPressEvent: key: " << keyEvent->key() << ", mode: " << keyEvent->modifiers() << endl;; }
and output is below.
# I press alt + f
keyPressEvent: key: 16777251, mode: 134217728
keyPressEvent: key: 70, mode: 134217728
# I press alt + space
keyPressEvent: key: 16777251, mode: 134217728i try to use event filter, and get the similar result.
bool eventFilter(QObject *object, QEvent *event) override { if (event->type() != QEvent::KeyPress) { return false; } QKeyEvent *keyEvent = dynamic_cast<QKeyEvent*>(event); fout << "eventFilter: key: " << keyEvent->key() << ", mode: " << keyEvent->modifiers() << endl;; }
-
i think i find the solution. use nativeEvent https://doc.qt.io/qt-5/qwidget.html#nativeEvent