Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am developing an application that will interact with USB devices. I want to pop up a message when a USB device is connected to the system. How can I do this using Qt. Is there any other library available to fire an event when a usb device is connected to the system.

I need an event or slot to when a new USB device connected to the system.
Posted
Comments
Jochen Arndt 17-Apr-13 5:45am    
Have a look at libudev (especially the udev_monitor_* functions). I have never used it but it should be what you are looking for.

1 solution

The library you're looking for is called INotify. As far as I know it sits on top of udev and gives you string based information about devices appearing and disappearing. I have seen and worked with code using it to detect the addition and removal of USB multi serial ports so it will do what you need.
The interface is just C calling convention from what I remember so you'll have no problem using it from Qt code. I'm not aware of any exisitng Qt support or Qt classes that would interect with this for you, there certainly weren't any in Qt4.

One piece of advice, if devices are being added and removed by users, get your FDDI chips serial numbered or buy/ship devices with them serial numbered. Users often expect to be able to remove a device from one USB port and put it in another for their own convinience and assume that the software will know that's what they've done and treat the device as the old one come back not a new one. This can be really tricky as udev and INotify doen't offer anything that automatically supports this.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900