Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QT for MacOS : QAbstractNativeEventFilter usb changes
Forum Updated to NodeBB v4.3 + New Features

QT for MacOS : QAbstractNativeEventFilter usb changes

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 429 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    inogeni
    wrote on last edited by
    #1

    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

    IPlayGenji6I 1 Reply Last reply
    1
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      That is speculation but I think you have to do some setup in order for your application to receive USB related events. This might be a starting point.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • I Offline
        I Offline
        inogeni
        wrote on last edited by
        #3

        Hi,

        Based on the link you provided, it seems i don't even need the QAbstractNativeEventFilter, as with the IOKit i can have the connection/disconnection events already .

        i will go with that from here .

        Thank you for your help !

        1 Reply Last reply
        1
        • I inogeni has marked this topic as solved on
        • I inogeni

          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

          IPlayGenji6I Offline
          IPlayGenji6I Offline
          IPlayGenji6
          wrote on last edited by
          #4

          @inogeni How do I change it if I want to use it on windows?

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved