The solution has been found. The following describes the most important part. The other part is not difficult. The problem mainly lies in how to find the USB flash drive insertion and dial-out, which can be achieved using the q6. The following is the connection. Code When a device is inserted, you can call the slotdeviceadded (qstring UDI) function.
In the pro file, add
Qt + = Success
Copy code
1. # include <qtdbus/qdbusconnection>
2. // The following is the insertion of the detection device.
3. qdbusconnection: systembus (). Connect ("org. freedesktop. Hal ",
4. "/org/freedesktop/hal/manager ",
5. "org. freedesktop. Hal. Manager ",
6. "deviceadded ",
7. This,
8. Slot (slotdeviceadded (qstring )));
9. // The following is the dial-out of the check device.
10. qdbusconnection: systembus (). Connect ("org. freedesktop. Hal ",
11. "/org/freedesktop/hal/manager ",
12. "org. freedesktop. Hal. Manager ",
13. "deviceremoved ",
14. This,
15. Slot (slotdeviceremoved (qstring )));
In the slotdeviceadded (qstring UDI) function
Copy code
1. qdbusinterface device ("org. freedesktop. Hal", Udi, "org. freedesktop. Hal. device", qdbusconnection: systembus ());
You can use Hal to query the volume device, and then determine whether it is a/dev/SD * device. Then you can determine whether it is a USB flash disk, and then call Mount.
At this time, record the UDI of the USB flash disk. when the device is detected to dial out, check whether the UDI of the USB flash disk is still there and check whether the USB flash disk is dropped out.