I have a problem serializing and reading back a QMap that holds a collection of my class called PID.
In this class I implemented operators << and >> as below, with the help of some good fellas here in this forum.
	
	- { 
-     out << pid.getKp() << pid.getKi() << pid.getKd(); 
-     return out; 
- } 
-   
-   
- { 
-     double kp; 
-     double ki; 
-     double kd; 
-     in >> kp >> ki >> kd; 
-     pid = new PID(); 
-     pid->setKp(kp); 
-     pid->setKi(ki); 
-     pid->setKd(kd); 
-     return in; 
- } 
        QDataStream &operator <<(QDataStream &out, const PID &pid)
{
    out << pid.getKp() << pid.getKi() << pid.getKd();
    return out;
}
QDataStream &operator >>(QDataStream &in, PID *pid)
{
    double kp;
    double ki;
    double kd;
    in >> kp >> ki >> kd;
    pid = new PID();
    pid->setKp(kp);
    pid->setKi(ki);
    pid->setKd(kd);
    return in;
}
To copy to clipboard, switch view to plain text mode 
  
Latter the map is serialized like this 
	
	- PID pid; 
-     pid.setKp(34); 
-     pid.setKi(45); 
-     pid.setKd(54); 
-             + name + TXT_FILE_EXT; 
-     QMap<quint8, PID*> pidList;  
- stream << pidList; 
-   
-     pidList.clear(); 
-     stream.device()->reset(); 
-   
-     stream >> pidList; 
-   
-     qDebug() << "Pid map size: " << pidList.size() << " File Size: "<< pidFile.size(); 
-     pidFile.close(); 
        PID pid;
    pid.setKp(34);
    pid.setKi(45);
    pid.setKd(54);
QString path = appDir.path() + QDir::separator()
            + name + TXT_FILE_EXT;
    QFile pidFile(path);
    pidFile.open(QIODevice::ReadWrite);
    QDataStream stream(&pidFile);
    QMap<quint8, PID*> pidList; 
stream << pidList;
    pidList.clear();
    stream.device()->reset();
    stream >> pidList;
    qDebug() << "Pid map size: " << pidList.size() << " File Size: "<< pidFile.size();
    pidFile.close();
To copy to clipboard, switch view to plain text mode 
  when I run this I get the same "Pid map size:  0  File Size:  8 " even when the map's size is changed in the code. Any Idea how I can get to my goal of serializing the collection of PIDs to a file and read back?
Thanks.
				
			
Bookmarks