when I list entries via QDir::entryInfoList I'm getting two extra entries, one with dot and second one with two dots. If I set QDir::NoDot and QDir::NoDotDot then nothing is listed. I need just the contents of the folder I'm passing to QDir, nothing else.
QFileInfo fi(model_->filePath(e));
auto file_path = fi.absoluteFilePath();
auto lyst = QDir(fi.absoluteFilePath()).entryInfoList(/*QDir::NoDotAndDotDot makes lyst empty*/);
foreach (QFileInfo info , lyst)
{
qDebug() << info.absoluteFilePath();
}
Pass QDir::NoDotAndDotDot filter ORed with QDir::Files or anything of your interest to entryInfoList
auto lyst =
QDir(fi.absoluteFilePath()).entryInfoList(QDir::NoDotAndDotDot|QDir::AllEntries);
According to this post:
The default value for the filter flags is
QDir::AllEntries. When you override the default flags withQDir::setFlagsorQDir::entryList, you should not forget to include at least one ofQDir::Dirs,QDir::Files, orQDir::Drivesto get any entries.
I imagine your code would look like this (haven't tested it):
QFileInfo fi(model_->filePath(e));
auto file_path = fi.absoluteFilePath();
auto lyst = QDir(fi.absoluteFilePath()).entryInfoList(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Files);
foreach (QFileInfo info , lyst)
{
qDebug() << info.absoluteFilePath();
}
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