My code is pretty simple:
void DirManagement::listFiles(QDir dir)
{
QFileInfoList list = dir.entryInfoList(QDir::NoFilter, QDir::NoSort);
for (int i = 0; i < list.size(); ++i)
{
QFileInfo fInfo = list.at(i);
QString fPath = fInfo.absoluteFilePath();
qDebug() << "# " << i << fPath; }
}
The problem is that, if my directory path is: "/home/adasi/Desktop/GCUFolder" this is the result:
# 0 "/home/Alya/Desktop/MCUFolder"
# 1 "/home/Alya/Desktop"
# 2 "/home/Alya/Desktop/MCUFolder/32Mon Oct 24 2011"
# 3 "/home/Alya/Desktop/MCUFolder/32Sun Oct 23 2011"
However, What I am expecting is ONLY whats under the given directory:
# 0 "/home/Alya/Desktop/MCUFolder/32Mon Oct 24 2011"
# 1 "/home/Alya/Desktop/MCUFolder/32Sun Oct 23 2011"
I tried most of the qt filters. Didn't work.
Just to add more information It worked like Mat said, specifying what you want to list, like this:
myQdirObject.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::NoSort);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With