Solid::DeviceNotifier Class
class Solid::DeviceNotifierThis class allow to query the underlying system for information about the hardware available. More...
| Header: | #include <Solid/DeviceNotifier> |
| CMake: | find_package(KF6 REQUIRED COMPONENTS Solid)target_link_libraries(mytarget PRIVATE KF6::Solid) |
Signals
| void | deviceAdded(const QString &udi) |
| void | deviceRemoved(const QString &udi) |
Static Public Members
| Solid::DeviceNotifier * | instance() |
Detailed Description
Applications should use this to be notified about hardware changes.
Note that it's implemented as a singleton and encapsulates the backend logic.
Member Function Documentation
[signal] void DeviceNotifier::deviceAdded(const QString &udi)
This signal is emitted when a new device with the given udi appears in the underlying system.
[signal] void DeviceNotifier::deviceRemoved(const QString &udi)
This signal is emitted when a device with the given udi disappears from the underlying system.
[static] Solid::DeviceNotifier *DeviceNotifier::instance()
Returns a pointer to the global DeviceNotifier instance to allow for its use with QObject::connect();
auto notifier = Solid::DeviceNotifier::instance();
auto refresh = [this] (const QString &udi) {
Solid::Device device(udi);
if (device.is<Solid::StorageDrive>()) {
qInfo() << "A new storage drive was added!";
}
};
QObject::connect(notifier, &Solid::DeviceNotifier::deviceAdded, refresh);