Object serialization with QDataStream
Hello,
I am trying to overload operators << and >> for QDataStream and my class. I checked some tutorials and have been trying to use them for my issue and got it almost right. When I write to a file I believe it works properly as I checked a file with binary editor. It surely saves QStrings properly. I can't tell anything about QDate and QTime variables as they don't appear in understandable way in Hex Fiend. Also I am aware that constructor is not used properly as when it isn't commented out it makes my app crash. So any hints to make it proper would be greatly appreciated.
Code:
bool isDone;
bool neededReminder;
quint32 time;
in >> name >> description >> dayClicked >> start >> end >> reminderTime >> isDone >> neededReminder >> time;
qDebug() << name << description << dayClicked.toString() << start.toString() << end.toString()
<< reminderTime.toString() << isDone << neededReminder << time;
task = Task(isDone, name, description, dayClicked, start, end, (int)time, neededReminder);
return in;
}
What qDebug is returning: "" "" "" "00:00:00" "00:00:00" "" false false 0
Re: Object serialization with QDataStream
Quote:
Also I am aware that constructor is not used properly as when it isn't commented out it makes my app crash. So any hints to make it proper would be greatly appreciated.
Constructor of what?
Quote:
What qDebug is returning: "" "" "" "00:00:00" "00:00:00" "" false false 0
Is this incorrect? How are you creating the stream you are reading from? Are you reading the data from where you think you are reading from? Are the fields written to the stream in the same order you are reading them?