PDA

View Full Version : Detecting changes to file system for QFileSystemModel



blackmarlin
9th October 2012, 16:14
Hi,

I have a QFileSystemModel connected to a QTreeView. The items in the QFileSystemModel are checkable and I need to be able to correctly map the checked items to the corresponding location in the underlying file system. Now, what is a good way to detect if files and folders are added or removed from the directory structure monitored by the QFileSystemModel? I.e. are there any signals I can connect to in order to keep my mapping updated?

Lesiok
9th October 2012, 16:18
Read about QFileSystemWatcher

blackmarlin
9th October 2012, 16:28
Ok. So I need to set up a separate QFileSystemWatcher for this, and can't indirectly or otherwise rely on the watcher used by the QFileSystemModel itself.

Thanks.

wysota
10th October 2012, 10:13
Since this is a model, you can connect to appropriate signals from QAbstractItemModel like rowsInserted().

blackmarlin
10th October 2012, 17:29
That's what I was looking for. Thanks a lot.