Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ Linux
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 22:25pm
Comments
Jochen Arndt at 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
good
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.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 505
1 Maciej Los 325
2 Richard MacCutchan 265
3 Mathew Soji 220
4 BillWoodruff 210
0 OriginalGriff 8,804
1 Sergey Alexandrovich Kryukov 7,457
2 DamithSL 5,689
3 Maciej Los 5,279
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web03 | 2.8.1411028.1 | Last Updated 17 Apr 2013
Copyright © CodeProject, 1999-2014
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