#include <QtCore/QCoreApplication>
#include <QVariant>
#include <QtDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QVariantMap map;
map["foo"] = QVariant(QVariantMap());
map["baz"] = "asdf";
qvariant_cast<QVariantMap>(map["foo"])["bar"] = "a";
qDebug() << qvariant_cast<QVariantMap>(map["foo"])["bar"].toString();
qDebug() << map["baz"].toString();
return a.exec();
}
I am trying to assign to a QVariant within a nested QVariantMap. The first qDebug() outputs nothing, but the second outputs "asdf" as expected. How would I assign the "bar" key in the nested variable map to a value?