PDA

View Full Version : QDeviceWatcher-Make hotplug detection easy



ibingow
11th September 2011, 08:09
It's my project: https://github.com/wang-bin/qdevicewatcher
It works fine on linux and windows. I have tested on my ubuntu and win7. Usually you just need the signals deviceAdded(const QString& device) and deviceRemoved(const QString& device) in QDeviceWatcher.

To detect the device changes, i use netlink in linux(kernel 2.6) and internel window in windows.
In windows, I tried two method, QCoreApplication::winEventFilter(MSG* msg, long* result) and QWidget::winEvent(MSG* msg, long* result). I hope my class is just a subclass of QObject, and do not use GUI module, so I started to find other ways. At last I refer to qdrive project: https://gitorious.org/qdrive/qdrive.