You have to know your offeset when accesing it, not way around it.how can i get the offset of anotherINT8 ?
(so in the example you gave you have to know how many baytes are written before 'anotherINT8')
But usually, you would use structures in order to serialize data, and not write just like that in to a file.
So for exmple, you could create a struct or a class called DataBlock, in which each field would have a name and type.
Like so:
typedef struct DataBlock {
Q_UINT32 blockNum;
Q_UINT8 feild1;
QString feild2;
float feild3;
}
You then can overload the global QDataStream & operator<<() and QDataStream & operator>>() to make reading and writing data blocks easy.
All you need then is to know in which block the feild you are looking for is at, read that much blocks, and expose the field.





Reply With Quote
Bookmarks