Unsolved QSettings with QDateTime changes between 5..3.2 and 5.8
-
Hi all,
I just upgraded from QT 5.3.2 to 5.8 and Iam writing settings to an ini file on Windows10. I encounter compatibility problems between the two versions.When I save it like this:
settings.setValue("recentfiles/AccessDate", info.LastAccessTime);
Then with 5.3.2 it will save in my ini file:
AccessDate=@Variant(\0\0\0\x10\0%\x80\xd1\x1\xfd\xc3/\xff)
But with 5.8 it will write:
AccessDate=@DateTime(\0\0\0\x10\0\x80\0\0\0\0\0\0\0\xff\xff\xff\xff\0)
Reading it like this
info.LastAccessTime = settings.value("AccessDate").toDateTime();
Works ok for 5.8 for both dialiects but the 5.3.2 fails to read the newer @QDateTime
Is there a fix to this? I was hoping to remain compatible. -
I Just found out that it must be related to this issue:
https://codereview.qt-project.org/#/c/126279/ -
@Richard I would use http://doc.qt.io/qt-5/qdatetime.html#toString and specify format. This way you do not depend on how Qt is serializing QDateTime. And it is readable by humans :-)