监听test111目录,发现在目录中增加,删除文件或文件夹时,directoryChanged 信号可以触发;改变该文件夹名称却不触发。
Watcher::Watcher(QWidget *parent)
: QWidget(parent)
{
QStringList args=qApp->arguments();
QString path;
if(args.count()>1)
{
path=args[1];
}
else
{
path=QDir::currentPath();
}
path= path+"/../test111";
pathLabel = new QLabel;
pathLabel->setText(tr("鐩戣�鐨勭洰褰曪細")+path);
QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->addWidget(pathLabel);
fsWatcher.addPath(path);
connect(&fsWatcher,SIGNAL(directoryChanged(QString)),this,SLOT(directoryChanged(QString)));
}
Watcher::~Watcher()
{
}
void Watcher::directoryChanged(QString path)
{
QMessageBox::information(NULL,tr("鐩�綍鍙戠敓鍙樺寲"),path);
}