View Single Post
Posts: 190 | Thanked: 129 times | Joined on Mar 2010 @ Bavaria, Germany
#2
First, please make the writing function const.
Code:
QDataStream &operator<<(QDataStream &out,  const Service &service);
QDataStream &operator>>(QDataStream &in, Service &service);
The second is, you can only use non-pointer types of Service when exporting the whole QList to a QDataStream. The following would work:
Code:
QList<Service> services;
mystream << services;
If you can't change to non-pointer type, you will have to iterate through the list at your own.
Code:
QList<Service*> services;
mystream << services.size();
foreach(Service* service, services)
  mystream << *service;
Edit: Also please stay away from creating QList<>s on the heap

the strange thing is that << seems to work with QList<Service*>!
If that's the only problem, try this:
Code:
mystream << *services;

Last edited by gri; 2010-06-03 at 21:52.
 

The Following 2 Users Say Thank You to gri For This Useful Post: