it appears that the QFileSystemWatcher's documentation may be improved.
Step to reproduce :
1/ create a watcher and add a file
2 / edit the file in an editor (works when using gedit)
3/ save the file
=> the signal fileChanged(QString) is emitted
=> the file is no more watched and the signal won't be emitted if the file is modified again if the file is modified again.
The reason is the following :
1/ In most editors, "save" is implemented with "delete the file / recreate the file".
2/ deleting the file causes the file to be removed from the watcher => it is no more monitored, even though the path is immediately recreated.
This behaviour is perfectly logical, and is not a bug.
But it is worth being mentioned in the documentation !!!
I propose to add something like the following to the QFileSystemWatcher doumentation :
Note : note that when "saving" a file, many editors actually delete the file, then recreate it. In that case, the QFileSystemWatcher will emit the fileChanged(QString) signal once. However, since the file is deleted, it will be removed from the monitored file list : future modification of the file won't be monitored anymore, since it is actually another file (though with the same path).
Workarround : when the fileChanged(QString) is received, check if the file has been removed from the monitored file list. If it has been removed, but if the path still exists on drive, readd the path to the monitored file list :