PDA

View Full Version : Serialization problem



ayanda83
23rd September 2012, 17:08
Hi everyone, I been given a task to serialize a QList of pointers to objects. The objects are of type "Film" with member variables "Film name", "Film ID", "Film Director" etc. The serializer object must display the above info in a file "myFile.txt" and I must also create another serializer to read the info from the file back into the QList as film objects. I've managed to to write the program except the function to read the data from the file back into the QList. I'm failing to get that function right. Any help will be appreciated.

Robbie
23rd September 2012, 17:21
How are you writing the data to the file (i.e. in what format)? Are you using QDataStream?

ayanda83
23rd September 2012, 17:44
I am using QTextStream.

Added after 19 minutes:

If I can know how to read a text file word by word, my problem will be solved.

wysota
23rd September 2012, 17:52
If I can know how to read a text file word by word, my problem will be solved.

QString word;
while(!file.atEnd()) {
stream >> word;
doSomethingWith(word);
}