Can linux signal my Qt program when a particular U

2019-06-06 05:28发布

I want linux to inform my Qt program by a signal when a particular USB device is connected. Storage devices like flash disk or hard drive. How can I do this? What are your suggestions?

UPDATE:

I have found that QtDbus can provide the functionality that I need but I have not figure out how exactly. Is there anyone can give information about getting USB device notification with QtDbus?

I have been reading this tutorial:
http://dbus.freedesktop.org/doc/dbus-tutorial.html

This tutorial says:
D-Bus is designed for two specific cases:

  • Communication between desktop applications in the same desktop session; to allow integration of the desktop session as a whole, and address issues of process life-cycle (when do desktop components start and stop running).
  • Communication between the desktop session and the operating system, where the operating system would typically include the kernel and any system daemons or processes.

I am planning to use this facility which I am asking for help in a non-graphical Linux system. More precisely on Beagleboard-XM with Angstrom Linux console image with QWS.

In this circumstances does QtDbus is a correct choice?

标签: qt4 usb signals
2条回答
男人必须洒脱
2楼-- · 2019-06-06 06:23

You might want to take a look with qdbusviewer from qt4-dev-tools what kind of dbus interface your system has regarding device notification (be it HAL or udev). Than it is relatively simple to generate a c++ implementation with qdbusxml2cpp. You will just have to connect to whatever dbus signal your system is suppling for device notification purposes. Here is a quick start guide for qt and dbus QtDbus Tutorual.

查看更多
ら.Afraid
3楼-- · 2019-06-06 06:31

Haven't tried Qt's DBUS implementation, but the general details of how to get a USB notification are in this tutorial

The QtDBus function names probably map onto these fairly easily

查看更多
登录 后发表回答