I actually also tried this to no avail. Is it a Windows plugin or native event filter bug that I cannot intercept alt+key presses? Or am I doing something wrong?
#include <QAbstractNativeEventFilter> #include <QApplication> #include <QMainWindow> #include <iostream> #ifdef Q_OS_WIN #include <windows.h> #endif class MyMSGEventFilter : public QAbstractNativeEventFilter { public: bool nativeEventFilter(const QByteArray &eventType, [[maybe_unused]] void *message, long *) override { #ifdef Q_OS_WIN if (eventType == "windows_generic_MSG" || eventType == "windows_dispatcher_MSG") { MSG *msg = static_cast<MSG *>(message); // This works if (msg->wParam == VK_SPACE) { std::cout << "TEST SPACE" << std::endl; } // None of these work. // else if (msg->wParam == WM_SYSKEYDOWN) { // else if (msg->wParam == VK_MENU) { else if (msg->wParam == VK_LMENU) { std::cout << "TEST ALT" << std::endl; } } #endif return false; } }; int main(int argc, char *argv[]) { QApplication app(argc, argv); MyMSGEventFilter filterObject; app.installNativeEventFilter(&filterObject); QMainWindow mainWindow; mainWindow.show(); return app.exec(); }
_______________________________________________ Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development