title: Detected new usb device connected/disconnected on Qt
body: <p>I want to be notified when a new usb device is connected or disconnected (device hid). I have succeeded to be notified when there is a usb device change but I don't know if the device is connected or disconnected. 
  The message I receive (when usb attached or detached) is the same : 
  message : 537 (VM_DEVICECHANGE)
  wParam : 7
  lParam : 0</p>
  
  <pre><code>#include &lt;QGuiApplication&gt;
  #include &lt;QQmlApplicationEngine&gt;
  #include &lt;QAbstractEventDispatcher&gt;
  #include &lt;QAbstractNativeEventFilter&gt;
  #include &lt;QDebug&gt;
  #include &lt;windows.h&gt;
  #include &lt;dbt.h&gt;
  #include &lt;QObject&gt;
  
  class MyNativeEventFilter : public QAbstractNativeEventFilter {
  public :
      virtual bool nativeEventFilter( const QByteArray &amp;eventType, void *message, long *result )
      Q_DECL_OVERRIDE
      {
          if (eventType == "windows_generic_MSG")
          {
            MSG *msg = static_cast&lt;MSG *&gt;(message);
            static int i = 0;
  
                msg = (MSG*)message;
                    qDebug() &lt;&lt; "message: " &lt;&lt; msg-&gt;message &lt;&lt; " wParam: " &lt;&lt; msg-&gt;wParam
                        &lt;&lt; " lParam: " &lt;&lt; msg-&gt;lParam;
                if (msg-&gt;message == WM_DEVICECHANGE)
                {
                    qDebug() &lt;&lt; "WM_DEVICECHANGE";
                }
              }
          return false;
      }
  };
  
  int main(int argc, char *argv[])
  {
      QGuiApplication app(argc, argv);
      MyNativeEventFilter myEventfilter;
      app.eventDispatcher()-&gt;installNativeEventFilter(&amp;myEventfilter);
      QQmlApplicationEngine engine;
      engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
  
      return app.exec();
  }
  </code></pre>