QT 实时监视文件夹


//
监控文件夹 void UpdateService::Monitor() { QString sPluginsPath = QString("%1/new").arg(QApplication::applicationDirPath()); m_pluginWatcher = new QFileSystemWatcher(); m_pluginWatcher->addPath(sPluginsPath); // 添加监视文件的路径 connect(m_pluginWatcher, SIGNAL(directoryChanged(QString)), this,SLOT(TriggerDirectoryChanged(const QString &))); } void UpdateService::TriggerDirectoryChanged(const QString &strpath) { //strpath为监视文件路径 }

需要添加头文件

#include <QFileSystemWatcher>

 

posted on 2020-09-17 10:31  缘随风烬  阅读(992)  评论(0编辑  收藏  举报