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

Sina Dogru sinadooru at gmail.com
Tue Mar 8 08:08:22 CET 2016


>
> Sure, you can look and see that the size() of a QByteArray returns
> an 'int', but that is only as of today. You should get into the habit
> of controlling the types written to QDataStreams.
>

That is a nice habit of programming tip! Thank you Bill, I will keep in my
mind for sure :)

2016-03-07 20:00 GMT+02:00 william.crocker at analog.com <
william.crocker at analog.com>:

>
>
>>>      QDataStream out2(&file); // and module A write those datas to a
>>> file.
>>>      out2 <<  bai.size();
>>>      out2 <<  bai;
>>>
>>
>>
> All of the following is IMHO:
>
> I think that if you are going to read the size back as an 'int'
> you should insure that an 'int' is written in the first place:
>
>     out2 << (int)bai.size();
>
> Sure, you can look and see that the size() of a QByteArray returns
> an 'int', but that is only as of today. You should get into the habit
> of controlling the types written to QDataStreams.
>
> Bill
>
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160308/fbbe010b/attachment.html>


More information about the Interest mailing list