PDA

View Full Version : Simple way to figure out if a QFile opened has been externally modified



kalos80
14th October 2010, 15:53
Hi,

In my text editor application, I would like to know if an opened file has been modified externally by another application in order to allow the user to reload it.

Is there an easy way to know that? I haven't find anything in QFile or QFileInfo classes.

Thanks in advance for your help

wysota
14th October 2010, 16:09
If your filesystem supports it, you can use QFileInfo::lastModified() to check for last modification date and compare it against the time when you saved the file last. But in general this is not reliable. Usually you use QFileSystemWatcher to monitor for modifications.

kalos80
14th October 2010, 17:43
wysota thank you very much for your hint!