PDA

View Full Version : How to read and insert key and Value in the 3D QMap



saad_saadi
23rd June 2014, 15:10
I am new Map in QT and have a 3D map like this


QMap<const char*, const char*> submap;
QMap<int, submap> map3D;

Now i inserted valued in it like this, the max of value of int is 5 but for each int value there is 50 key and value for submap.


1) How can i insert value in map3D. I am doing like this


submapD.insert(TempA,TempB);
map3D.insert(count,submap);

count value will be incremented after TempA and TempB values will be more than 50 values.
Can anyone tell how i can read it back from map3D?

Thanks

anda_skoa
23rd June 2014, 15:37
If you mean access by key, just chain two calls of QMap::value()



const char *value = map3D.value(someInt).value(someCharStar);


Btw, since you use a low level type (const char*) make sure the pointers stay valid during the life time of the map

Cheers,
_