[Development] Windows plugin customisation: QWindowsKeyMapper

Laszlo Papp lpapp at kde.org
Wed Aug 3 05:43:56 CEST 2022


Hi again,

I wrote this simple test bed, but it does not seem to work. It seems that
the windows plugin does not let me process the alt key after all? I can
process the space fine, but not the alt. Am I doing something wrong or the
windows plugin does not allow the api user to intercept the native events
via the intended native event filter?

#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
        // Does not work: if ((GetKeyState(VK_MENU) & 0x8000) &&
(GetKeyState(VK_SPACE) & 0x8000)) {
        // Does not work: if (GetKeyState(VK_MENU) & 0x8000) {
        // Does not work: if (GetKeyState(VK_LMENU) & 0x8000) {
        if (GetKeyState(VK_SPACE ) & 0x8000) { // Works
          std::cout << eventType.toStdString() << 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/7f8b98d3/attachment.htm>


More information about the Development mailing list