#include <QObject>
#include <QCoreApplication>
#include <QDebug>
#include <QFileSystemWatcher>
using namespace QObject;
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QFileSystemWatcher watcher;
watcher.addPath("/dev");
QObject::connect(&watcher, &QFileSystemWatcher::directoryChanged, [] (const QString &path) {
qDebug() << "Directory" << path << "has changed.";
// 在这里检查/dev目录下的文件变化
});
return a.exec();
}
离线