Results 1 to 2 of 2

Thread: Fast solution to list directories recursively

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2011
    Posts
    127
    Thanks
    42
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Fast solution to list directories recursively

    Do you know a faster solution to find all of the directories by Qt(QDirIterator is too slow)

    Qt Code:
    1. QDirIterator directories(dir_, QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
    2. while(directories.hasNext()){
    3. directories.next();
    4. dirs.push_back(directories.filePath());
    5. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. //codes base on BFS(breadth first search)
    2. QStringList scan_dir_recursive(QDir const &dir)
    3. {
    4. std::queue<QString> queue;
    5. queue.push(dir.absolutePath());
    6. QStringList results;
    7. while (!queue.empty()) {
    8. auto const subdir_name = queue.front();
    9. queue.pop();
    10. results.push_back(subdir_name);
    11. QDir subdir(subdir_name);
    12.  
    13. auto const &directories = subdir.entryInfoList({},
    14. QDir::AllDirs | QDir::NoSymLinks | QDir::NoDotAndDotDot);
    15. for (auto const &data : directories) {
    16. queue.push(data.absoluteFilePath());
    17. }
    18. }
    19.  
    20. return results;
    21. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by stereoMatching; 2nd February 2014 at 15:32.

Similar Threads

  1. Cound not find or load qt platform plugin windows... No working solution yet !
    By bouchebeu in forum Installation and Deployment
    Replies: 1
    Last Post: 28th October 2013, 00:52
  2. Replies: 0
    Last Post: 23rd November 2011, 15:14
  3. Return number of directories in a directories
    By franco.amato in forum Newbie
    Replies: 7
    Last Post: 29th September 2010, 23:29
  4. Fast Clipping [SOLUTION]
    By maverick_pol in forum Qt Programming
    Replies: 14
    Last Post: 24th October 2008, 12:30
  5. Recursively changing margins/padding
    By ghorwin in forum Qt Programming
    Replies: 3
    Last Post: 4th September 2007, 11:08

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.