c++ - 从控制台应用程序使用 QFileSystemWatcher
问题描述
我想从控制台应用程序中使用 QFileSystemWatcher,而我目前的方法没有收到任何被忽略的信号。谁能指出这个设置有什么问题?
static duk_ret_t automation_watch(duk_context *ctx)
{
int argc = 0; char** argv = 0;
QCoreApplication app(argc, argv);
bool retval = false;
QFileSystemWatcher *watcher = new QFileSystemWatcher(&app);
qDebug() << QDir::current().absolutePath();
watcher->addPath(QDir::current().absolutePath());
retval = QObject::connect(watcher, &QFileSystemWatcher::fileChanged, [](const QString& a) {
printf(a.toStdString().c_str());
printf("\r\n");
return 0;
});
assert(retval == true);
retval = QObject::connect(watcher, &QFileSystemWatcher::directoryChanged , [](const QString& a) {
printf(a.toStdString().c_str());
printf("\r\n");
return 0;
});
assert(retval == true);
app.exec();
return 0;
}
解决方案
推荐阅读
- angular - Angular 4:如何在模态引导程序中发送用户的 ID
- c# - net.core / asp.net identity / openid connect 中的关联失败
- css - CSS 网格元素未正确对齐
- r - r - 按顺序创建绘图并排列在多个页面上
- python - Python:查找字符串中的所有整数并作为整数存储在列表中
- javascript - 尝试通过 xmlhttprequest 提交 html 表单数据
- php - 在 Laravel 中运行功能测试时如何模拟服务(或服务提供者)?
- javascript - 自定义我的谷歌地图信息窗口内容
- r - R中不同版本的GlobalOptions包
- python - python根据字符串表示将元组添加到列表中