Hi
I am trying to traverse a directory so I made the following code:
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)
{
if(file.isDir())
qDebug() << "- (dir): " << file.absoluteFilePath();
else
qDebug() << "- : " << file.absoluteFilePath();
}
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();
}
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!
Bookmarks