Results 1 to 4 of 4

Thread: Notifying QFileSystemModel about changes

  1. #1
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Notifying QFileSystemModel about changes

    I have a QFileSystemModel with a custom QSortFilterProxyModel and a custom QFileIconProvider.

    My QFileIconProvider fetches file icons in another thread so that the file list can be populated more quickly - get file list first, populate list, and then get the icons in a seperate thread. So my QFileIconProvider::icon() override returns a blank icon until the information is available. How can I get QFileSystemModel to recognise when the new icon is available? I don't want want to refresh the entire list, as I want the list to update as and when the icons become available.

  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: Notifying QFileSystemModel about changes

    Emit dataChanged() for each modified index.
    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. #3
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Notifying QFileSystemModel about changes

    I would normally use that in a model to notify the widget that the data is changed and to refresh it. However, here I don't control the data in the model as it's a QFileSystemModel, and since QFileSystemModel caches the data, will dataChanged actually have any effect? Or will it just retrieve the data from the cache ?

    I know it can handle changes from its thread internally, but thats all hidden in QFileSystemModelPrivate.

  4. #4
    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: Notifying QFileSystemModel about changes

    It's best to just check what QFileSystemModel::data() returns for decoration (and FileIconRole) role. I would guess emitting dataChanged() is the only thing you can do with the model here. Otherwise apply a proxy over the model and return icons from the proxy - then you'll have full control over what is going on.
    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.


Similar Threads

  1. QFileSystemModel file icon overlays
    By squidge in forum Qt Programming
    Replies: 2
    Last Post: 18th October 2009, 11:06
  2. Known problem with filters and QFileSystemModel?
    By Kumosan in forum Qt Programming
    Replies: 3
    Last Post: 27th August 2009, 08:14
  3. QDirModel or QFileSystemModel?
    By ricardo in forum Qt Programming
    Replies: 1
    Last Post: 21st June 2009, 17:10
  4. QFileSystemModel has no sorting
    By mpi in forum Qt Programming
    Replies: 3
    Last Post: 28th May 2009, 08:14
  5. Notifying Mainwindow of an event..
    By MrGarbage in forum Qt Programming
    Replies: 1
    Last Post: 9th November 2007, 21:29

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.