通知短信+运营短信,5秒速达,支持群发助手一键发送🚀高效触达和通知客户 广告
[TOC] ## 概述 可见监听文件或目录变更 ## 示例 ``` #include <QCoreApplication> #include <QFileSystemWatcher> #include <QDebug> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); // 创建一个 QFileSystemWatcher 对象 QFileSystemWatcher watcher; // 要监视的目录或文件的路径 QString pathToWatch = "/path/to/your/directory"; // 添加要监视的目录或文件 watcher.addPath(pathToWatch); // 连接文件或目录发生变化时触发的信号到槽函数 QObject::connect(&watcher, &QFileSystemWatcher::directoryChanged, [&](const QString &path) { qDebug() << "Directory changed:" << path; }); QObject::connect(&watcher, &QFileSystemWatcher::fileChanged, [&](const QString &file) { qDebug() << "File changed:" << file; }); qDebug() << "Watching directory:" << pathToWatch; return a.exec(); } ```