Basically I need to generate a nested QVariantMap. (Think JSON):
{ "foo" : 1, "bar" : { "node" : 0 } }
I do this in Qt this way:
QVariantMap r, r_bar;
r["foo"] = QVariant(1);
r_bar["node"] = QVariant(0);
r["bar"] = r_bar;
Which is very inconvenient for large nested structures. Is there an elegant way of doing this, such as this (fake syntax)?:
r["foo"] = QVariant(1);
r["bar"]["node"] = QVariant(0);
I cannot do this:
r["foo"].toMap()["node"] = QVariant(0)
because all "toSomething" functions of QVariant return a copy of the object, not a reference to it.
Can anyone help me with this?
Thanks!