我需要在 qt 中查看目录。创建了连接。但是当文件编辑时,发件人会发出两次目录更改信号。filechanged 信号也同时发出。两次发射信号有什么用?有没有办法知道哪个文件/文件夹被更改了?请帮忙..这是连接代码
QFileSystemWatcher *watcher = new QFileSystemWatcher;
watcher->addPath("/home/user/directory/");
connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(directoryChangedHandler(QString)));
和功能
void MainWindow::directoryChangedHandler(QString path)
{
QMessageBox::information(0, "Directory Changed", "Directory Changed at " + path);
}