Results 1 to 6 of 6

Thread: how to recursive a directory in qt?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2006
    Posts
    8
    Qt products
    Qt3 Qt/Embedded
    Platforms
    Unix/X11

    Post Re: how to recursive a directory in qt?

    i use qt/e2.3.10, my code is below, but it doesn't work, why?

    Qt Code:
    1. int addFileFromDir(const QString& d)
    2. {
    3. QDir dir( d );
    4. dir.setMatchAllDirs( true );
    5. dir.setSorting(QDir::DirsFirst | QDir::IgnoreCase);
    6. if( !dir.exists() )
    7. {
    8. return -1;
    9. }
    10. QString file;
    11. const QFileInfoList * list = dir.entryInfoList();
    12. if( list )
    13. {
    14. QFileInfoListIterator it(*list);
    15. QFileInfo *fi;
    16. while ( (fi = it.current()) != 0 )
    17. {
    18. qDebug( fi->absFilePath() );
    19. if ( !fi->isDir() )
    20. {
    21. //do something
    22. }
    23. else if ( fi->isDir() && (fi->fileName()!=".") && (fi->fileName()!="..") )
    24. {
    25. addFileFromDir( fi->absFilePath() );
    26. }
    27. ++it;
    28. }
    29. }
    30. return 0;
    31. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jacek; 7th November 2006 at 01:50. Reason: missing [code] tags

  2. #2
    Join Date
    Mar 2006
    Posts
    8
    Qt products
    Qt3 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: how to recursive a directory in qt?

    i know why, there is another bug in other code
    thank you all the same!

Similar Threads

  1. QDirModel - show directory ".."?
    By jamd in forum Qt Programming
    Replies: 3
    Last Post: 23rd April 2009, 19:51
  2. Difference a file and a directory
    By xgoan in forum Qt Programming
    Replies: 3
    Last Post: 11th August 2006, 12:02
  3. create file in another directory
    By raphaelf in forum Qt Programming
    Replies: 3
    Last Post: 16th February 2006, 10:04
  4. Am I the only one with "make" error ?
    By probine in forum Installation and Deployment
    Replies: 1
    Last Post: 13th February 2006, 12:54
  5. QT Service and working directory
    By Lele in forum Qt Programming
    Replies: 1
    Last Post: 23rd January 2006, 11:46

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.