[Development] QVariantMap <-> QML

Gerhard Scheikl g.scheikl at avibit.com
Sun Jun 14 19:43:34 CEST 2015


Hi

I recently discovered some unexpected behavior when exchanging a QVariantMap 
with QML code:

Here's what I'm doing on the C++ side:
my_map = json_document.toVariant();
engine.rootContext()->setContextProperty("myMap", my_map);

Then on the QML side:
myMap.asdf.name = "asdf"

This change is not reflected in the original map.
Obviously, accessing asdf.name returns a copy.

Is this the intended behavior?
If so, how can I ensure that the data in C++ and on the QML side is always the 
same?
(use QJSValue? use a QObject hierarchy with dynamic properties?)

Thanks!

Best regards
Gerhard



More information about the Development mailing list