QT for MacOS : QAbstractNativeEventFilter usb changes
Solved
General and Desktop
-
Hello everyone,
I try to use the QAbstractNativeEventFilter class to handle connections/disconnections of an usb device on a Mac .
i followed the example in the documentation , but so far, i am unable to receive notifications when a device is connected or disconnected , only some mouse related events.i've already used this class for a windows implementation, and i had no problem, but on mac no success at all.
here is what i have so far:
class MyClassForEventFilters : public QAbstractNativeEventFilter { public: bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *){ if (eventType == "mac_generic_NSEvent"){ qDebug() << "received event..."; return true; } return false; } }; int main(int argc, char* argv[]){ QGuiApplication app(argc, argv); // some code related to the QQmlApplicationEngine... MyClassForEventFilters filters; app.installNativeEventFilter(&filters); return app.exec(); }
could you explain what i'm doing wrong or missing on MacOS, please ?
thank you in advance for any help
-