I don't think so, according to the documentation, you will get a path of the changed directory, as the object can watch multiple directories at once.
void QFileSystemWatcher::directoryChanged ( const QString & path ) [signal]
This signal is emitted when the directory at a specified path, is modified (...)
You can keep track of the directory content yourself:
class MyClass ... {
private slots:
void directoryChanged(const QString& path);
private:
};
...
MClass::MyClass(...)
{
connect(&_watcher,
SIGNAL(directoryChanged
(QString)),
this,
SLOT(directoryChanged
(QString)) );
}
void MyClass::startMonitor(const QString& path){
_watcher.addPath(path);
_currentEntryList = dir.entryList();
}
void MyClass::directoryChanged(const QString& path){
// now in "files" you have current content of directory
// and in variable "_currentEntryList" you have previous content of directory
// so in order to know which files were added or removed you can compare the two lists
... <code to find the difference between two string lists>
//
_currentEntryList = files;
}
class MyClass ... {
private slots:
void directoryChanged(const QString& path);
private:
QFileSystemWatcher _watcher;
QStringList _currentEntrylist;
};
...
MClass::MyClass(...)
{
connect(&_watcher, SIGNAL(directoryChanged(QString)), this, SLOT(directoryChanged(QString)) );
}
void MyClass::startMonitor(const QString& path){
_watcher.addPath(path);
const QDir dir(path);
_currentEntryList = dir.entryList();
}
void MyClass::directoryChanged(const QString& path){
const QDir dir(path);
const QStringList files = dir.entryList();
// now in "files" you have current content of directory
// and in variable "_currentEntryList" you have previous content of directory
// so in order to know which files were added or removed you can compare the two lists
... <code to find the difference between two string lists>
//
_currentEntryList = files;
}
To copy to clipboard, switch view to plain text mode
Bookmarks