I have a problem with QDir, I have this folder with lots of images, and I need to iterate through them but, they have to be sorted, so, I'm using setSorting(QDir::Name)
however, It doesn't work on Ubuntu. When I iterate it with QDirIterator it selects pictures in given folder randomly. The weird thing is I use the same exact code on Windows (minGW or MSVC) and It works perfectly.
someClass::someClass(QDir dir) {
m_dir = dir;
m_directory.setSorting(QDir::Name);
QStringList filter;
filter << QString("*.") + format << QString("*.") + "jpg";
m_dir.setNameFilters(filter);
}
someClass::iterateDir() {
QDirIterator it(m_dir);
while(it.hasNext()) {
it.next();
qDebug() << it.fileName();
//analayze the picture here
}
}
here it.fileName()
should print (0.jpeg, 1.jpeg .... 3000.jpeg) but instead it prints (2342.jpg, 1286.jpg, 684.jpg ... 712.jpg) I tried to use other sortFlags
(QDir::Size, QDir::LocaleAware
) but none of them works on Ubuntu.
Is there something I'm missing?
Thank you for your time.