Sorting with multiple conditions in QDir::entryInfoList
Frage
Qt's doc says that QDir::entryInfoList
can accept multiple sorting conditions but how to do is unclear to me.
This enum describes the sort options available to QDir, e.g. for entryList() and entryInfoList().
The sort value is specified by OR-ing together values from the following list:
QDir::Name 0x00 Sort by name.
QDir::Time 0x01 Sort by time (modification time).
:
(snip)
I assume OR-ing
needs to be done somehow by can't think of how for now (I think have to go back and review bit-shifting?) but could someone tell me how? Appreciate it.
(Anyway this description isn't clear as a document for high-level language?)
Lösung
QDir::SortFlags
is actually a typedef of QFlags<QDir::SortFlag>
, type-safe way of storing OR-combinations of enum values.
So what you do is simply QDir::Name | QDir::Time
in your case as the argument to QDir::entryInfoList()
method.
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow