QJsonObject in header and QString/QVariant
-
Hey,
im trying to create a QJsonObject.
First Problem i want to create the QJsonObject in my Header …xyz.h:
#include <QJsonObject> ... QJsonObject jsonView;
xyz.cpp:
jsonView{ {hgz.name, hgz->value().first().valuemn.toString()} }
i geht the following error:
expected ';' before '{' tokenif i create the QJsonObject in the .cpp file everything is working fine.
This version working:xyz.cpp
QJsonObject jsonView{ {hgz.name, hgz->value().first().valuemn.toString()} }
i Need the JsonObject in my Controller so i should have global Access thats why i Need the JsonObject in my Header.
The secound Problem:
i want to create a QJsonObject with an String and a QVariant.
{QString, QVariant}
any Ideeas?
-
@NotYourFan said in QJsonObject in header and QString/QVariant:
QJsonObject jsonView;
With a C++11 compiler you can initialise jsonView in the header.
"i want to create a QJsonObject with an String and a QVariant" - what would be the content of that QVariant?
-
@NotYourFan said in QJsonObject in header and QString/QVariant:
i want to create a QJsonObject with an String and a QVariant.
{QString, QVariant}
any Ideeas?
You cannot store a QVariant in a QJsonObject.
You can store Booleans, numbers, strings, JSON arrays, or JSON objects in a QJsonObject.