PDA

View Full Version : QDir entryInfoList and NoDotAndDotDot filter



invictus
25th February 2009, 21:45
Hi

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


QDir root("c:\\Qt");

qDebug() << "dirName(): " << root.dirName() << ", absolutePath(): " << root.absolutePath();

//http://doc.trolltech.com/4.4/qdir.html#Filter-enum
QFileInfoList fList = root.entryInfoList(QDir::NoDotAndDotDot, QDir::DirsFirst);

for(int i=0;i < fList.size(); ++i)
{
QFileInfo file = fList.at(i);
if(file.isDir())
qDebug() << "- (dir): " << file.absoluteFilePath();
else
qDebug() << "- : " << file.absoluteFilePath();
}

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!

spirit
26th February 2009, 06:27
try this


...
QFileInfoList fList = root.entryInfoList(QDir::AllDirs | QDir::NoDotAndDotDot, QDir::DirsFirst);
...