QSettings
-
hi freinds i want write array of json value to QSettings ini file
below example
[ "ID": 570, "picture": "03803.png", "name": "Bob"]how to write to QSettings file. any example
-
@satyanarayana143 said in QSettings:
any example
Read documentation, there are examples: https://doc.qt.io/qt-5/qsettings.html
Also, QSettings does not use JSON format. -
You may want to save a QJsonDocument
-
@satyanarayana143
For an example of how to save JSON viaQSettings
you might read through https://stackoverflow.com/questions/42060573/save-ui-settings-with-qsettings-or-qjson.There are known issues with
QSettings
which might occur with a JSON entry. Also, your JSON will probably have newlines in it, I don't know whetherQSettings
handles this for you (I think settings entries in the file have to be on one line), and/or "special" characters in the JSON which just might tripQSettings
up.If it all works as-is, fine. If not, just be aware that you could always use https://doc.qt.io/qt-5/qbytearray.html#toBase64 to encode the JSON before saving, and https://doc.qt.io/qt-5/qbytearray.html#fromBase64 to decode upon reload, if required and that solves issues.