Results 1 to 6 of 6

Thread: how to list out all files in a dir and sub dir

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2006
    Location
    Bangalore,India
    Posts
    235
    Qt products
    Qt3 Qt4
    Platforms
    Windows
    Thanks
    7
    Thanked 25 Times in 24 Posts

    Unhappy Re: how to list out all files in a dir and sub dir

    Thanks Jacek,


    Your code solved only 2nd requirement. But my basic requirement is how to get subdirectories file?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: how to list out all files in a dir and sub dir

    Qt Code:
    1. QString nameFilter( "*.txt" );
    2. QDir::Filter filter = QDir::AllDirs | QDir::NoDotAndDotDot | QDir::Hidden | QDir::NoSymLinks;
    3.  
    4. push dir
    5. while not empty:
    6. pop dir
    7. foreach( const QFileInfo& entry, dir.entryInfoList( nameFilter, filter ) ) {
    8. if( entry.isDir() ) {
    9. push entry.dir();
    10. }
    11. else {
    12. // ...
    13. }
    14. }
    15. }
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to jacek for this useful post:

    rajesh (14th August 2006)

  4. #3
    Join Date
    May 2006
    Location
    Bangalore,India
    Posts
    235
    Qt products
    Qt3 Qt4
    Platforms
    Windows
    Thanks
    7
    Thanked 25 Times in 24 Posts

    Default Re: how to list out all files in a dir and sub dir

    Jacek,
    push pop gives complier error

  5. #4
    Join Date
    May 2006
    Location
    Bangalore,India
    Posts
    235
    Qt products
    Qt3 Qt4
    Platforms
    Windows
    Thanks
    7
    Thanked 25 Times in 24 Posts

    Default Re: how to list out all files in a dir and sub dir

    Thanks Jacek,
    I used QList and done push and pop, so its working now.
    Thanks again.

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.