PDA

View Full Version : QDir::NoDotAndDotDot hidding all files?



been_1990
2nd July 2009, 19:00
When I use QDir::NoDotAndDotDot, my QtDir gives me an empty string. But when I remove it all files are outputted.Any idea why this strange behaviour? And why these ".",".." appear? Thanks.:)

shentian
2nd July 2009, 21:53
The default value for the filter flags is QDir::AllEntries. When you override the default flags with QDir::setFlags or QDir::entryList, you should not forget to include at least one of QDir::Dirs, QDir::Files, or QDir::Drives to get any entries.



// output a list of all subdirectories except "." and ".."
foreach(QString entry, QDir("mydir").entryList(QDir::NoDotAndDotDot | QDir::Dirs))
{
qDebug() << entry << ", ";
}

been_1990
3rd July 2009, 04:12
Thank you.