[Development] Windows plugin customisation: QWindowsKeyMapper
Laszlo Papp
lpapp at kde.org
Wed Aug 3 06:37:13 CEST 2022
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();
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20220803/50ef444e/attachment.htm>
More information about the Development
mailing list