i want to detect any changes in a directory uncluding subfolders :
exemple : if i put a listner in the directory D:\dropbox i want my application shows this :
- D:\dropbox\folder1\file1.txt is deleted
- D:\dropbox\folder1\folder2 is created
- D:\dropbox\public is modified
- ...
i have found this exemple in the internet but it show only a simple message : "the directory is changed "
please can any body help me ?
#ifndef MYCLASS_H
#define MYCLASS_H
#include <QWidget>
#include <QMessageBox>
class MyClass : public QWidget
{
Q_OBJECT
public:
MyClass(QWidget* parent=0)
:QWidget(parent){}
~MyClass(){}
public slots:
void showModified(const QString& str)
{
Q_UNUSED(str)
QMessageBox::information(this,"Directory Modified", "Your Directory is modified");
}
};
#endif // MYCLASS_H
#include <QApplication>
#include <QFileSystemWatcher>
#include <QDebug>
#include "MyClass.h"
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QFileSystemWatcher watcher;
watcher.addPath("C:/QtTest");
QStringList directoryList = watcher.directories();
Q_FOREACH(QString directory, directoryList)
qDebug() << "Directory name" << directory <<"\n";
MyClass* mc = new MyClass;
QObject::connect(&watcher, SIGNAL(directoryChanged(QString)), mc, SLOT(showModified(QString)));
return app.exec();
}
Correct, Qt and QFileSystemWatcher cannot do more for you as of now. You can read more about the plans to extend the support but it is not yet there:
http://blog.rburchell.com/2012/03/qt-51-aka-when-qfilesystemwatcher-might.html
You would need to implement this yourself for each platform, but if you really are into that, you could talk to Robin to collaborate.
Here is part of the blog post to see what was being planned: