Results 1 to 5 of 5

Thread: Detecting changes to file system for QFileSystemModel

  1. #1
    Join Date
    Oct 2012
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Detecting changes to file system for QFileSystemModel

    Hi,

    I have a QFileSystemModel connected to a QTreeView. The items in the QFileSystemModel are checkable and I need to be able to correctly map the checked items to the corresponding location in the underlying file system. Now, what is a good way to detect if files and folders are added or removed from the directory structure monitored by the QFileSystemModel? I.e. are there any signals I can connect to in order to keep my mapping updated?

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,540
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Detecting changes to file system for QFileSystemModel

    Read about QFileSystemWatcher

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

    blackmarlin (9th October 2012)

  4. #3
    Join Date
    Oct 2012
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Detecting changes to file system for QFileSystemModel

    Ok. So I need to set up a separate QFileSystemWatcher for this, and can't indirectly or otherwise rely on the watcher used by the QFileSystemModel itself.

    Thanks.

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

    Default Re: Detecting changes to file system for QFileSystemModel

    Since this is a model, you can connect to appropriate signals from QAbstractItemModel like rowsInserted().
    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.


  6. #5
    Join Date
    Oct 2012
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Detecting changes to file system for QFileSystemModel

    That's what I was looking for. Thanks a lot.

Similar Threads

  1. Detecting QIcon failed load from file
    By spraff in forum Qt Programming
    Replies: 2
    Last Post: 7th July 2013, 00:54
  2. Replies: 4
    Last Post: 20th April 2011, 12:15
  3. QFileSystemModel file icon overlays
    By squidge in forum Qt Programming
    Replies: 2
    Last Post: 18th October 2009, 11:06
  4. detecting that a file is currently being written to...
    By momesana in forum Qt Programming
    Replies: 11
    Last Post: 31st October 2007, 13:02
  5. Detecting the last empty line in a file
    By Ti_Thom in forum Qt Programming
    Replies: 2
    Last Post: 19th October 2006, 05:14

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
  •  
Qt is a trademark of The Qt Company.