Il 18/05/2018 21:27, Jason H ha scritto:
I've got a QVariantMap that contains QVariantMaps. (I kinda posted about this 
Wednesday, when I was having a few issues at the same time).
I'm essentially trying to do

map["a"]["b"]["c"] = QPoint(0,0);

However, because I'm using QVariant maps, I have to do:
QVariantMap a = map["a"].toMap();
QVariantMap b = a["b"].toMap();
b["c"]=QPoint(0,0);

But that detaches from b and gives me a new container modified b, and it doesnt 
appear in the hierarchy. I have to:

This has nothing to do with detaching / COW; this has to do with the fact that toMap() gives you a _copy_ of the contents of the variant at a["b"]. From that moment on you're modifying b, which is a totally independent object from the one contained in a["b"]. As far as I know, there's no API to avoid the copy and reference directly the contents of a variant.

My 2 c,
--
Giuseppe D'Angelo | giuseppe.dang...@kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts

Attachment: smime.p7s
Description: Firma crittografica S/MIME

_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to