Qt QfileSystemWatcher没有';行不通
以下是我初始化监视程序的方式:Qt QfileSystemWatcher没有';行不通,qt,filesystems,filesystemwatcher,Qt,Filesystems,Filesystemwatcher,以下是我初始化监视程序的方式: QFileSystemWatcher watcher; bool isWatched = watcher.addPath("../stylesheets/main.style"); if (isWatched) qDebug() << "Stylesheet is being watched."; connect(&watcher, &QFileSystemWatcher::fileChanged, this, &
QFileSystemWatcher watcher;
bool isWatched = watcher.addPath("../stylesheets/main.style");
if (isWatched) qDebug() << "Stylesheet is being watched.";
connect(&watcher, &QFileSystemWatcher::fileChanged, this, &PCLViewer::updateStyle );
updateStyle
函数的签名如下:
public slots:
void updateStyle(const QString &path);
我正在使用ubuntu。插槽函数签名错误。我必须使用
voidupdatestyle(qstringpath)代码>,以便调用它。如果有人有相同的问题
试试这个:
QFileSystemWatcher *watcher = new QFileSystemWatcher();
bool beingWatched = watcher->addPath("Enter your path here");
if (beingWatched ) qDebug() << "Being watched";
QObject::connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(handleFileChanged(QString)));
QFileSystemWatcher*watcher=new QFileSystemWatcher();
bool beingWatched=watcher->addPath(“在此处输入您的路径”);
到目前为止,如果(被监视)qDebug()代码片段看起来是正确的。请发布一个更完整的代码示例。您是否尝试使用文件的完整路径?是的,我厌倦了完整路径和另一个文件,但两者都不起作用!
QFileSystemWatcher *watcher = new QFileSystemWatcher();
bool beingWatched = watcher->addPath("Enter your path here");
if (beingWatched ) qDebug() << "Being watched";
QObject::connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(handleFileChanged(QString)));