[Qt-interest] Adding quint32 to a QByteArray
Francisco Gonzalez
gzmorell at gmail.com
Tue Sep 7 20:30:24 CEST 2010
Sorry is: QDataStream stream(&array, QIODevice::ReadWrite);
but it do not answer the question :).
2010/9/7 Francisco Gonzalez <gzmorell at gmail.com>
> Hello,
> Afaik QByteArray class have not a function to add a quint32 data directly
> at some position, (nor any other integer, float or doble types) in a
> platform independent manner.
> Instead it is possible to do:
>
> quint32 number = anyNumber;
> qint64 position = anyPositionNumber;
> QByteArray array;
> QDataStream stream(QByteArray& array, QIODevice::ReadWrite);
> stream.setByteOrder(QDataStream::LittleEndian); // The endian type you want
> stream.device()->seek(position);
> stream << number;
>
>
> Is there any other option to get this directly to a QByteArray in a
> platform independent way?
>
> Thanks,
> Francisco González
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100907/65cd0798/attachment.html
More information about the Qt-interest-old
mailing list