Reputation: 23
I have a QStringList
that gets all the files in a certain directory, and all the files are created by another function, hence, they are created at the same date. The problem is when I call "entryList()" in my QStringList
, it orders the files from oldest to newest, and I want to reverse it.
jsonList = dirTweetJson.entryList(QDir::AllEntries | QDir::Files | QDir::NoDotAndDotDot);
// dirTweetJson is the QDir of my files
Upvotes: 2
Views: 1338
Reputation: 4582
You have to override default alphabetic sort using SortFlag: QDir::Time
jsonList = dirTweetJson.entryList(QDir::AllEntries |
QDir::Files | QDir::NoDotAndDotDot, QDir::Time);
you can reverse the sort order using QDir::Reversed
along with your sort falg:
jsonList=dirTweetJson.entryList(QDir::AllEntries | QDir::Files |
QDir::NoDotAndDotDot, QDir::Time | QDir::Reversed);
Upvotes: 2