[Interest] reading from and writing to a file with QDataStream
Thiago Macieira
thiago.macieira at intel.com
Tue Mar 8 18:30:24 CET 2016
On terça-feira, 8 de março de 2016 09:05:50 PST Sina Dogru wrote:
> Thank you for writing Thiago,
>
> > The problem is here. You've removed the bug from the sample source. So we
> > can't help you.
>
> Well I might made a mistake, I am kind of a amatuer programmer but on the
> real code, the problem is also same. I mean after I read stream to string,
> string is empty.
> But for now it is working. Like you and others pointed, the problem was I
> was reading different size of bytes.
The problem is that the section you commented out could have hidden other
bugs. You didn't show how module A added to the data to be transmitted.
> > Most likely module A is overwriting the byte array, instead of appending
> > to
> > it.
>
> I approach to QByteArray like std::string.
That doesn't mean anything.
> > Did you really mean to write a datastream that contains a datastream
> > inside?
> > Did you mean to nest one inside the other?
>
> Ah can you be more specific please? Because I have just cheated from qt-docs
> <http://doc.qt.io/qt-5/qdatastream.html#details> writing to and reading
> from a file if you are talking about constructing a QDataStream from a
> QFile.
Indeed, but look at how you've combined two or more examples. You have a byte
array, you create a QDataStream on it, write some data, then you used
QDataStream to write that byte array to another byte array. You probably
didn't want that.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
More information about the Interest
mailing list