Click here to Skip to main content
13,146,395 members (48,542 online)
Rate this:
Please Sign up or sign in to vote.
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 16-Apr-13 21:25pm
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

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.170915.1 | Last Updated 17 Apr 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100