开发者

Read QByteArray setting written by QSetting within different Qt version.

开发者 https://www.devze.com 2023-03-05 10:31 出处:网络
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).

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号