#include #include #include #include #include #include int main(int argc, char* argv[]) { QCoreApplication app(argc, argv); QFileSystemWatcher* watcher = new QFileSystemWatcher(); watcher->connect(watcher, &QFileSystemWatcher::fileChanged, [&] { std::cout << "done\n"; app.quit(); }); auto path = R"(C:\Users\Philippe\MyTextFile.txt)"; { std::ofstream f(path, std::ios::out | std::ios::trunc | std::ios::binary); f.close(); } watcher->addPath(path); //std::this_thread::sleep_for(std::chrono::milliseconds(50)); std::ofstream f(path, std::ios::out | std::ios::trunc | std::ios::binary); f.close(); return app.exec(); }