0

I'm using pyqt treview and QFileSystemModel to display my computer files and plugged in USB devices. What I want is to be able to detect when devices are connected to the computer and show only those in the treeview. For example, on windows, when I do model.setRootPath('') , it shows me the connected devices and the C: drive. I only want the connected devices to show. And if there is none, the treeview should be blank until a device connected for it to update.

After some searches, I've already written the code for detecting connected devices (for both windows and Linux). Using QTimer, the code checks every 0.5 seconds for new/removed devices. I just need a way to filter out everything else and only show the connected devices. I need this for both Linux and Windows, if possible.

Thanks in advance for every help

SorinT
  • 53
  • 1
  • 6
  • 1
    Consider a [QSortFilterProxyModel](https://doc.qt.io/qt-5/qsortfilterproxymodel.html) subclass and override [`filterAcceptsRow()`](https://doc.qt.io/qt-5/qsortfilterproxymodel.html#filterAcceptsRow). – musicamante Jan 26 '22 at 19:09
  • @musicamante Thank you for the suggestion. I'll try this and see if I get something out of it – SorinT Jan 26 '22 at 20:15

0 Answers0