Custom sortable columns in QFileSystemModel
-
Thast's why https://doc.qt.io/qt-6/qfilesystemmodel.html#lastModified is there.
-
@Jo-Jo
I now see that, and see from https://codebrowser.dev/qt5/qtbase/src/widgets/dialogs/qfilesystemmodel.cpp.html#737 that it is called in the implementation ofQFileSystemModel::data()
for column #3, which is what I needed to know.I also see it is formatted as a string with
QLocale::ShortFormat
. I don't know what that looks like, I don't know how "precise" it is (e.g. down to, say, milliseconds or likely not?), I don't know what the locale-aware formatting does with it. Putting all these together it would not surprise me if it is unsuitable for sorting, and/or for converting back (accurately) to a datetime/comparing. Whereas thebirthTime()
you use for your extra column is indeed a datetime type and is suitable.Hence, as both I and @Christian-Ehrlicher have said, I would use
lastModified()
just as you usebirthDate()
for this column in your own code fordata()
method. -
@Christian-Ehrlicher @JonB agree with you guys about lastModified, thanks!
21/23