Results 1 to 2 of 2

Thread: QDir entryInfoList and NoDotAndDotDot filter

  1. #1
    Join Date
    Feb 2007
    Posts
    61
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QDir entryInfoList and NoDotAndDotDot filter

    Hi

    I am trying to traverse a directory so I made the following code:

    Qt Code:
    1. QDir root("c:\\Qt");
    2.  
    3. qDebug() << "dirName(): " << root.dirName() << ", absolutePath(): " << root.absolutePath();
    4.  
    5. //http://doc.trolltech.com/4.4/qdir.html#Filter-enum
    6. QFileInfoList fList = root.entryInfoList(QDir::NoDotAndDotDot, QDir::DirsFirst);
    7.  
    8. for(int i=0;i < fList.size(); ++i)
    9. {
    10. QFileInfo file = fList.at(i);
    11. if(file.isDir())
    12. qDebug() << "- (dir): " << file.absoluteFilePath();
    13. else
    14. qDebug() << "- : " << file.absoluteFilePath();
    15. }
    To copy to clipboard, switch view to plain text mode 

    However, this returns an empty list. If I disabled the NoDotAndDotDot filter it show the directory correctly (including the dot and dotdot I want to filter). Anyone know what I am doing wrong? Perhaps I have misinterpreted the function of the NoDotAndDotDot filter?

    I appreciate any feedback on this issue. Thanks!

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QDir entryInfoList and NoDotAndDotDot filter

    try this
    Qt Code:
    1. ...
    2. QFileInfoList fList = root.entryInfoList(QDir::AllDirs | QDir::NoDotAndDotDot, QDir::DirsFirst);
    3. ...
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

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.