How can one obtain the changed file names from the QFileSystemWatcher directoryChanged
event?
Asked
Active
Viewed 1,409 times
1
1 Answers
0
You need to connect your slot to the fileChanged()
signal instead of directoryChanged()
if you are more interested in the file names.
connect(&myFileSystemWatcher, SIGNAL(fileChanged(const QString&)), SLOT(handleFileChanged(const QString&)));
Then, you can just use the slot argument as desired. Here, I am just printing it out to stdout:
void handleFileChanged(const QString &path)
{
qDebug() << path;
}
Please see the documentation for further details:
void QFileSystemWatcher::fileChanged(const QString & path) [signal]
This signal is emitted when the file at the specified path is modified, renamed or removed from disk.
Not sure how much you are familiar with the Qt signal/slot system, but if not enough, please go through this, too:

Community
- 1
- 1

László Papp
- 51,870
- 39
- 111
- 135
-
As for add, modify and delete distinction, [this post](http://blog.rburchell.com/2012/01/qfilesystemwatcher-internals-in-qt-5.html) might be useful for the readers from Robin. – László Papp Apr 20 '14 at 10:36