rakkar
30th October 2009, 15:32
Hi,
Currently, I allow loading and saving of my application using code as follows:
QDataStream dataStream;
dataStream.setDevice(&file);
QByteArray geo_data = saveGeometry();
QByteArray layout_data = saveState();
dataStream << geo_data;
dataStream << layout_data;
dataStream << databases;
dataStream << mostRecentProjectPath;
dataStream << mostRecentDatabasePath;
dataStream << mostRecentLayoutPath;
...
The problem with this is that for future versions, the format of the save file may change. I may need more fields, or fields may no longer apply, or they may be in a different order.
Since I'm probably not the first person to encounter this, I wanted to see if other people had suggestions on the best approach to handle this. Right now I'm thinking if QT has a way to save using something like QXMLDataSTream that would be perfect. With XML, if a field doesn't exist already I could use a default, and I can ignore fields that no longer apply.
I also like the idea of XML because it can be version controlled and modified by hand.
Thanks in advance for any advice.
Currently, I allow loading and saving of my application using code as follows:
QDataStream dataStream;
dataStream.setDevice(&file);
QByteArray geo_data = saveGeometry();
QByteArray layout_data = saveState();
dataStream << geo_data;
dataStream << layout_data;
dataStream << databases;
dataStream << mostRecentProjectPath;
dataStream << mostRecentDatabasePath;
dataStream << mostRecentLayoutPath;
...
The problem with this is that for future versions, the format of the save file may change. I may need more fields, or fields may no longer apply, or they may be in a different order.
Since I'm probably not the first person to encounter this, I wanted to see if other people had suggestions on the best approach to handle this. Right now I'm thinking if QT has a way to save using something like QXMLDataSTream that would be perfect. With XML, if a field doesn't exist already I could use a default, and I can ignore fields that no longer apply.
I also like the idea of XML because it can be version controlled and modified by hand.
Thanks in advance for any advice.