[Qt-interest] Adding quint32 to a QByteArray

Jason H scorp1us at yahoo.com
Tue Sep 7 20:38:18 CEST 2010


QDataStream + QBuffer?





________________________________
From: Francisco Gonzalez <gzmorell at gmail.com>
To: qt-interest at trolltech.com
Sent: Tue, September 7, 2010 2:24:12 PM
Subject: [Qt-interest] Adding quint32 to a QByteArray

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/b20f9bc7/attachment.html 


More information about the Qt-interest-old mailing list