Results 1 to 2 of 2

Thread: QFileSystemModel and QDirModel

  1. #1

    Question QFileSystemModel and QDirModel


    i wanted to use a model to select a folder in a treeview and then get directories and files within this folder.
    i picked QDirModel and saw the following remark :

    The usage of QDirModel is not recommended anymore. The QFileSystemModel class is a more performant alternative.
    so i decided to use QFileSystemModel :
    - i waited a few seconds each time i launched the program for the explorer to be displayed
    - i tried to retrieve the number of rows at a given index but since the expanding process is asynchronous, it was difficult to retrieve the result.
    - i tried then to list the children of a given index with a QDir object, but i couldn't set the same sort order for QFileSystemModel and QDir. For example, QFileSystemModel sorts numbered files like this : 3, 10, 2000 ... and QDir sorts the same files like this : 10, 2000, 3.

    Since i needed the same sort order for my program, i finally gave up QFileSystemModel and tried the deprecated QDirModel.

    And then i was surprised to see that :
    - i didn't have to wait for the explorer to be displayed
    - the expanding process was synchronous and the rowCount result was the expected one
    - i could set the same flags for the sort order (QDir::SortFlags), or use only the QDirModel to get the children (synchronous process).

    So my questions are the following ones :

    Did i misunderstand the usage of QFileSystemModel in one or more of the three cases given above ?

    If I did not, could it be possible to take into account these previous remarks to improve the QFileSystemModel or to make another class in case we would need the old QDirModel functionalities ?

    Thanks for reading, and sorry if i made any language mistake (English is not my native language).

  2. #2
    Join Date
    Oct 2011
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi PyQt3 PyQt4
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QFileSystemModel and QDirModel

    Waiting for the answer....

Similar Threads

  1. QFileSystemModel with checkboxes...
    By been_1990 in forum Qt Programming
    Replies: 14
    Last Post: 11th March 2011, 15:01
  2. how use QFileSystemModel with QListView ?
    By lwifi in forum Qt Programming
    Replies: 4
    Last Post: 26th April 2010, 03:41
  3. Help with QFileSystemModel
    By TheShow in forum Qt Programming
    Replies: 4
    Last Post: 5th January 2010, 20:11
  4. Notifying QFileSystemModel about changes
    By squidge in forum Qt Programming
    Replies: 3
    Last Post: 23rd November 2009, 23:24
  5. QDirModel or QFileSystemModel?
    By ricardo in forum Qt Programming
    Replies: 1
    Last Post: 21st June 2009, 17:10


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.