QT Desktop USB Device Pluged/Unpluged Detection Based On PID&VID
-
Hello everyone.
I am new around. So if I do a mistake, please forgive me. First, a short brief about myself.
I am +10 years of experience embedded system developer. So I know a couple of things about C programming language (Not cpp sadly). And I know a couple of things about C#. That means I also develop .Net desktop applications. So I have some habits from the .Net platform.
Now, I have a question.
Currently, I am developing a test application to learn more about the QT platform.
This application will connect to a USB Device (most probably an HID device).
My expectation from the application is that it can detect when a USB device is inserted/removed.
I can do it on .Net easily. But I am not sure how to do this in QT.
On .Net, some OS hook functions notify me about the device insertion or removal. Is there anything like that in QT or how can I do this on QT?BTW, I bought a course on Udemy which is well known Bryan Cairns's course. He has 3 of them with different levels. I bought all three. I hope I choose the correct course. Is there any alternative suggestion to help me to improve myself?
-
Hi and welcome to devnet,
AFAIK, not directly however, KDE has the Solid framework that you can use for that purpose.
-
USB control/enumeration is a platform dependent function so will be different between Unix/Linux, Mac, and Windoze. In Linux the kernel generates catchable events when USB devices are added/deleted.
-
I think, there has to be a way to do this. Windows has that feature too. I used it with C# .Net. I believe there is a way to do this with QT.
Does libusb help me with this? -
i used this library to print on usb printer.
https://github.com/fpoussin/QtUsbShould be useful in your case. It detects the connection/disconnection of the device.
-
@piervalli
I have looked your link and seems very nice. But there is a problem.
I am using MinGWx64 but that library build around msvc. Is it possible to compile that library with mingw? -
@yldzmuhammed you need to compile by source to use Mingw, I use the same compiler (8.1)
-
@piervalli can you guide me how to do this? I am new at this. How can I do? Can you share some keywords?
-
Sorry for delay, I lost the post. I not am an export for C++, but I have fixed errors for Mingw, I pushed it on github, try to compile (8.1 5.15.2).
https://github.com/piervalli/QtUsb -