Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
991 views
in Technique[技术] by (71.8m points)

c++ - Is there a Qt solution for detecting USB events (insertion and removal)?

As some other people already asked here some years ago, I want to be able to detect in a Qt application when a pendrive/datatraveler is plugged and when it is unplugged in my system (both in Linux Ubuntu and Embedded Linux).

I searched in SO and I noticed that most answers not only were very outdated (from 2010 for example), but all solutions somehow involved "non-Qt solutions" to these problem: either platform specific or usage of external libraries such as udev and DBus.

What I want to know first of all is if there is a specific Qt solution for this, i.e. a way to do this without requiring adding external libs or platform specific codes, and how could I use it. Preferentially it should already be available in Qt 4.8. If there is no Qt solution, then a Qt-based library would be acceptable.

Add: Search results:

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

As already pointed out, Qt itself does not provide such a module. There is however a user-made class called QDeviceWatcher. I have no experience with it personally and it is not updated regularly but you could give it a try.

You can find the forum post here and the git repository here.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...