tags:

views:

89

answers:

3

I have 2 datas which type is QMap:

1.QMap novel; QString tempChapter; QString tempStory;

2.QMap combo; int tempInd; QString tempChap;

my question is: How can I save these 2 Datas into a single file?? And if it's successfully saved, how can I load these 2 datas? Please insert the code too because I'm a beginner C++ programmer and dont know much about OOP,, please answer this ASAP! Thank you very much! :)

A: 

Basically, you will have to think of a format to store your data in yourself. I would suggest to read something about serialization. Read this for some general information about serialization in C++.

Job
thanks for always answering my questions :)but in the end, i still dont get this QMap thing,, lolguess i have to learn about Qt more,,
Hanny
It's not really a Qt thing. Just find a way to represent a map as text. You could, for example, write one line per key/value pair and separate each pair by some special character(s). This is really easy to write and parse.
Job
+2  A: 

All of the basic collections in qt are supported by QDataStream check for support in the QMap docs, as you are only storing other basic qt types and ints you should be ok

Harald Scheirich
He, didn't know that. Much better than my idea:) +1
Job