I am a bit lost with QVariantMAP/List and reference.
I load a json with QJson and convert it to QVariantMAP. currentJSON["tests"] is a QVariantList
I wish to browse currentJSON["tests"] and update the value of item["label"]. The first loop try to update the value, the second display it. Unfortunately the value display is not the updated value. I suppose this is a copy/reference problem but I do not find how to fix it.
QVariantMap currentJSON = jObject.toVariantMap(); //jobject is the json
QVariantList l = qvariant_cast<QVariantList>(currentJSON["tests"]);
for (QVariantList::iterator hehe = l.begin(); hehe != l.end(); hehe++) {
QVariantMap test = hehe->toMap();
test["label"].setValue(QVariant("AAAAAAAAAAAAAAAAAAA"));
}
l = qvariant_cast<QVariantList>(currentJSON["tests"]);
for (QVariantList::iterator hehe = l.begin(); hehe != l.end(); hehe++) {
QVariantMap test = hehe->toMap();
//the value print is not AAAAAAAAAAAAAAAAAAA
qDebug() << test["label"].toString();
}
If you can help me, thank.