wang-bin/qdevicewatcher

QDeviceWatcher not working on Windows

DonaldDuck313 opened this issue · 1 comments

I tried using the following simple code on Windows to detect when devices are inserted or removed:

QDeviceWatcher deviceWatcher;
QObject::connect(&deviceWatcher, &QDeviceWatcher::deviceAdded, [](){
    qDebug() << "Device added";
});
QObject::connect(&deviceWatcher, &QDeviceWatcher::deviceChanged, [](){
    qDebug() << "Device changed";
});
QObject::connect(&deviceWatcher, &QDeviceWatcher::deviceRemoved, [](){
    qDebug() << "Device removed";
});

I tried inserting/removing several USB devices while this program was running, but none of these signals were ever emitted. The USB devices that I tried were a USB mouse and an Android phone with a USB cable.

Did you at the HotplugWatcher example?