I have a QTreeView which is populated through a reimplementation of QFileSystemModel. As far as I know, QFileSystemModel installs a QFileSystemWatcher on the rootPath. What I’m trying to do is notify in my program when a file is being deleted directicly on the rootPath but i havent found any signal o reimplemented function which provides me that information.
My application upload some files thrugh an ftp connection and when the file is fully uploaded i remove it from the location, so i want a notification from the reimplementation of QFileSystemModel when the file is deleted directicly (not from the remove method or something similar).
I Hope you can help me. I have searched a lot on the web but I cant find anything.
Cheers.
You can use the
FileSystemModel‘srowsAboutToBeRemovedsignal (inherited fromQAbstractItemModel).It will be fired whenever a row is removed from the model. The
parent,startandendparameters allow you to get to the filename (in column 0 of the children).Sample code:
(Using std::cout isn’t good practice with Qt I think, this is just to get you started.)
The other
aboutToBe...signals from QAbstractItemModel can be used for the other events that happen on the filesystem.