qt服务器 接收不到文件,Windows上的Qt QFileSystemWatcher不发送fileChanged()信号

我正在跟踪另一个应用程序更改的日志文件。 在Linux中,一旦其他应用程序更改文件,我就会正确接收到fileChanged信号。 在Windows中,QFileSystemWatcher不会发出任何fileChanged信号,直到其他应用程序closures。

我试图用记事本打开日志,以确保实际上已被更改,只要记事本打开日志,QFileSystemWatcher发送fileChanged信号。

我的代码:

void LogLoader::createFileWatcher() { if(fileWatcher != NULL) delete fileWatcher; fileWatcher = new QFileSystemWatcher(this); connect(fileWatcher, SIGNAL(fileChanged(QString)), this, SLOT(prepareLogWorker(QString))); if(fileWatcher->addPath(logPath)) { qDebug() << "LogLoader: "<< "FileWatcher linked."; } } void LogLoader::prepareLogWorker(QString path) { //Added this just in case because I read it as solution //in other question. But in my case the file is not removed. if (!fileWatcher->files().contains(path)) { fileWatcher->addPath(path); } QTimer::singleShot(1000, this, SLOT(sendLogWorker())); }

难道我做错了什么? 有没有其他解决scheme,而不是手动检查文件?

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值