[Interest] Avoiding COW with Qt Containers.

Jason H jhihn at gmx.com
Fri May 18 21:27:47 CEST 2018


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:
a["b"]=b;
map["a"] = a;

And then the value "sticks".

Is where a way I can:
1. more concisely address map["a"]["b"]["c"]
2. avoid the re-assignment up the tree
Of those two, 2 is by far the most important. 




More information about the Interest mailing list