Try using QFileSystemWatcher and connect to the fileChanged() signal. When the signal is sent with the name of the file you are interested in, then you know it has changed. At that point, you can re-read the file.
When you read the file with QFile, you basically create a copy in memory of the contents of the file at the time you read it. This in-memory data does not change when the file changes, because it is a copy.
If you want the in-memory data to be up to date, then you need to watch the file for changes (which QFileSystemWatcher will do for you) and re-read the file when you see it has changed. Be sure to close the file after you read it, otherwise the other app that is changing it may not be able to open it if you have it open and locked.




Reply With Quote
Bookmarks