Read QByteArray setting written by QSetting within different Qt version.
QByteArray is serialized in different formats on the file system if the different version of Qt library is used (say 4.5.2 against 4.7.1).
I use the QSettings in my application to store the some binary data in the .ini
file. Now application is migrated to Qt 4.7.1 and if updated version of app reads (using the QSettings value method) the resulted QByteArray is not equal to the serialized by previous version of app.
Possible solution:
maintain the version of Qt used by app (I store the app version in the settings)
implement the own format for QSet开发者_开发技巧tings (wrapper for ini format) with own ReadFunc and WriteFunc.
read/write QByteArray settings using the QDataStream within setVersion using the maintained Qt version.
Any more simple solutions?
QDataStream's setVersion is the simplest and quickest way.
http://doc.qt.io/qt-4.8/qdatastream.html#setVersion
and for future reference the Qt5 version:
http://doc.qt.io/qt-5.5/qdatastream.html#setVersion
精彩评论