qt-interest@trolltech.com
[Top] [All Lists]

Re: [Qt-interest] Write struct in a QByteArray or QFile

Subject: Re: [Qt-interest] Write struct in a QByteArray or QFile
From: Thiago Macieira
Date: Mon, 08 Jun 2009 18:12:34 +0200
Oliver.Knoll@xxxxxxxx wrote:
> It is not very obvious from the docs
> http://doc.qtsoftware.com/4.5/qiodevice.html#write, but I think write()
> writes an 8-bit string (characters) to the file, that is it terminates
> when it encounters a NUL (\0) character (or when it has written
> 'maxSize' characters, whatever comes first). Actually the Qt docs only
> mention the string here:
> http://doc.qtsoftware.com/4.5/qiodevice.html#write-2, a method which
> was only introduced in Qt 4.5:
>
>    "Writes data from a zero-terminated string of 8-bit characters to
> the device."
>
>But I think this comment also applies to
> http://doc.qtsoftware.com/4.5/qiodevice.html#write.

No, it doesn't. The write() function writes binary data. If a size isn't 
given, then it writes until the first NUL -- but if it is given, then it 
writes exactly that many bytes.

>Especially since there are methods in the API which specifically deal
> with binary data, such as:
>
>  http://doc.qtsoftware.com/4.5/qiodevice.html#writeData

That's a protected virtual function that is called by write() to actually 
write data. It's not what you're looking for.

-- 
Thiago Macieira - thiago.macieira (AT) nokia.com
  Senior Product Manager - Nokia, Qt Software
      Sandakerveien 116, NO-0402 Oslo, Norway
_______________________________________________
Qt-interest mailing list
Qt-interest@xxxxxxxxxxxxx
http://lists.trolltech.com/mailman/listinfo/qt-interest
<Prev in Thread] Current Thread [Next in Thread>