Trolltech Home | Qt-solutions Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-solutions Archive, December 2006
Help on serialization?


Message 1 in thread

Hi.

I am new to QTLib and I have a problem and not sure where to look for 
information. I wrote a class, say Class C; and would like to know how do 
I serialize the class I wrote so when I use a QDataStream object to do a 
<<, it will write my object into a binary file. Any example or pointer 
to look for any information will be appreciated.

Summary.
1. Wrote a class called Class C and the object, obj.
2. Opened a QFile and attach it to a QDataStream object that is called fout.
3. Would like to know what do I need to do so I can call do a "fout << 
obj;" in my code.

Thank you.

--
 [ signature omitted ] 

Message 2 in thread

Jason M. schrieb:
> 3. Would like to know what do I need to do so I can call do a "fout << 
> obj;" in my code.


Simple: Implement a << operator and, if you want do de-serialize the 
object later, a >> operator, to write and read the objects properties 
to/from a stream. You may want to consult a good C++ book, as this is 
not Qt specific.
BTW, you may want to subscribe to the list qt-interest, as this list is 
specific for a commercial product called "Qt Solutions".

Martin

-- 
 [ signature omitted ]