[Interest] reading from and writing to a file with QDataStream

Nikita Krupenko krnekit at gmail.com
Tue Mar 8 13:57:36 CET 2016


2016-03-08 9:25 GMT+02:00 André Somers <andre at familiesomers.nl>:
> Actually, for reading and writing binary data files, I think it is wise to
> get into the habbit of using explicitly sized types. That is, write out and
> read back a qint8, a qint32 or a qint64, not an int or a long. int and other
> integer types are not guaranteed to be the same size across platforms, so
> you may get into trouble if you are not explicit about how many bytes you
> want or expect your values to be encoded in.

One more important thing: don't forget to explicitly set stream
version! As the way classes are serialized can change in future Qt
versions (and often changes).



More information about the Interest mailing list