Results 1 to 3 of 3

Thread: Simple way to figure out if a QFile opened has been externally modified

  1. #1
    Join Date
    Mar 2006
    Posts
    56
    Thanks
    7
    Thanked 3 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Simple way to figure out if a QFile opened has been externally modified

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Simple way to figure out if a QFile opened has been externally modified

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    kalos80 (14th October 2010)

  4. #3
    Join Date
    Mar 2006
    Posts
    56
    Thanks
    7
    Thanked 3 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Simple way to figure out if a QFile opened has been externally modified

    wysota thank you very much for your hint!

Similar Threads

  1. Replies: 1
    Last Post: 11th October 2010, 10:21
  2. Draw figure underneath other figure
    By Mnemonic in forum Qt Programming
    Replies: 0
    Last Post: 7th April 2010, 13:38
  3. Form , set object externally
    By giacomelli.fabio in forum Newbie
    Replies: 10
    Last Post: 31st December 2009, 13:03
  4. Replies: 7
    Last Post: 22nd November 2009, 19:47
  5. figure out?
    By uygar in forum Qt Programming
    Replies: 3
    Last Post: 20th May 2009, 08:19

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.