I have a QHash and a seperate QMap. I can serialize them alone. But I would like to serilize them in a single file:
QMap<int,QString> myMap;
QHash<QString,MyCalss> myHash;
// .. fill: both have 4 (key,value) pairs.
// write here
QDataStream out (&myFile);
out<<myMap;
out<<myHash;
// read written
QDataStream in (&myFile);
in>>myMap>>myHash;
The last read (here myHash) is empty always. When I switch the ordering
QDataStream out (&myFile);
out<<myHash;
out<<myMap;
// read written
QDataStream in (&myFile);
in>>myHash>>myMap;
so here myMap is empty.
How can I serialize both simultaneously?
Whats wrong with
QDataStream out (&myFile);
out<<myMap;
out<<myHash;
// read written
QDataStream in (&myFile);
in>>myMap;
in>>myHash;
Serializing 'in' into the Hash and the Hash into the Map will not lead to the desired results.