[Interest] reading from and writing to a file with QDataStream
Sina Dogru
sinadooru at gmail.com
Tue Mar 8 07:54:30 CET 2016
> > QByteArray bai;
> > out2 << bai.size();
> > out2 << bai;
> Here you wrote out an int and a QByteArray, so the file contains 4 bytes
> for the int "bai.size()" (value of 22), and then because of how QDataStream
> serializes QByteArrays, another 4 bytes for the size of the QByteArray
> (still a value of 22), plus the contents of the QByteArray itself. At this
> point, remember that the contents of the QByteArray are 4 bytes for the
> size of the QString (value of 18) plus the QString in UTF-16 format.
Sean,
Thank you for explaining how QDataStream works actually. Since I got more
instinct about the subject, I can see how I made my mistake and some
unnecessary approach. For example reading differently then writing out. And
writing out the bytearray size :S.
Cheers,
Sina
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160308/1e19bbbb/attachment.html>
More information about the Interest
mailing list