I need to hide the cursor when USB mouse is disconnected from the system, and show it when the mouse is connected. Any ideas how it can be done?
Asked
Active
Viewed 831 times
1
-
Do you have X running on this system? If so you can try the methods [here](http://stackoverflow.com/questions/660613/how-do-you-hide-the-mouse-pointer-under-linux-x11#696855). – HeyYO Sep 26 '16 at 11:33
1 Answers
3
Qt itself does not provide such a module. There is a user-made class called QDeviceWatcher, you could give it a try.
If you are using QtEmbedded Linux, you have a folder with all USB devices info (vendor id, etc), probably in /proc/scsi/usb-storage
file. So you probably could use QFileSystemWatcher to handle modification in this folder.
See: Qt Centre Post for more detail.

mohabouje
- 3,867
- 2
- 14
- 28
-
`QFileSystemWatcher` on Linux uses `inotify`, but the entries in `/proc/` are not files. They do _look_ like files, in the sense that most entries contain text, but `inotify` doesn't work on them. And this isn't something that realistically can be fixed; some of these entries are continuously changing. – MSalters Sep 26 '16 at 13:08
-
QDeviceWatcher works well. However, it's a problem to understand that the device you connected is actually a mouse. A usb dongle is seen as an "USB Receiver" (for wired mouse it is "optical mouse"). Any ideas about that? – Dorin Botan Sep 26 '16 at 13:30