Results 1 to 2 of 2

Thread: Iterating with QDirIterator seems slow

  1. #1
    Join Date
    Oct 2009
    Posts
    11
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Iterating with QDirIterator seems slow

    I'm using QDirIterator to find all subdirectories based on a name filter like this:

    Qt Code:
    1. QStringList nameFilters;
    2. nameFilters << "*CAL*";
    3. QDirIterator dirIterator(path, nameFilters, QDir::Dirs, QDirIterator::Subdirectories);
    4. QStringList results;
    5. while (dirIterator.hasNext())
    6. {
    7. QString qstr = dirIterator.next();
    8. results << qstr;
    9. }
    To copy to clipboard, switch view to plain text mode 

    The path value is a directory that in this case contains over 30,000 files and 1,100 subdirectories. The code returns the correct result, but it is slow (5 seconds or more). It is interesting that the QDirIterator constructor above returns almost immediately, but the next() call within the loop is what takes so long. Is there any reason why this operation would take this long? There are less than 10 directories out of 1,100 that match the name filter, but it takes a long time just to iterate through them.

  2. #2
    Join Date
    Oct 2009
    Posts
    11
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Iterating with QDirIterator seems slow

    As a test, I ran the dos command:

    dir *CAL* /AD /S /B

    on the same directory and it was extremely fast in returning the desired result.


    Is there any Qt class that can provide this result with similar performance? This is a difference of a fraction of a second versus several seconds.

Similar Threads

  1. QDirIterator and windows drives
    By invictus in forum Qt Programming
    Replies: 0
    Last Post: 8th March 2009, 19:48
  2. Spectrogram too slow
    By a_kaa in forum Qwt
    Replies: 2
    Last Post: 9th January 2009, 16:57
  3. iterating selected rows in a qtableview
    By JeanC in forum Qt Programming
    Replies: 2
    Last Post: 19th January 2008, 14:29
  4. Iterating over QGroupBox
    By Doug Broadwell in forum Newbie
    Replies: 3
    Last Post: 26th February 2007, 22:13
  5. qt4 - iterating thru QListView
    By incapacitant in forum Newbie
    Replies: 3
    Last Post: 26th November 2006, 23:38

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.