Vote count:
0
Im using QTCreator and I have this structure:
typedef struct
{
QString i;
} stBookMark;
These are some of the includes:
...
#include <QFile>
#include <QJsonArray>
#include <QJsonDocument>
#include <QVariantList>
#include <QVariant>
#include <QMetaType>
And I also added this:
Q_DECLARE_METATYPE(stBookMark)
The problem is somewhere here:
stBookMark x;
x.i = "Hello";
QVariant c;
c.setValue(x);
QVariantList a;
a.append(c);
a.append(0);
a.append(-119);
qDebug()<<a;
QJsonArray list = QJsonArray::fromVariantList(a);
QJsonDocument saveDoc(list);
And the output .json file here:
[
null,
0,
-119
]
asked 1 min ago
QJson only saves null value in QT
Aucun commentaire:
Enregistrer un commentaire