[Qt-interest] how to output a user defined struct data to datastream?

Andre Haupt andre at bitwigglers.org
Thu Oct 13 11:05:25 CEST 2011


On Thu, Oct 13, 2011 at 04:49:27AM -0400, Vincent Cai wrote:
> Sorry, but I think the endian is controlled by QDataStream which is platform independent, am I wrong?

This is correct, as long as you use it the right way ;-)
You had a 16 bit member in your struct, but in your sample you passed
that member bytewise to QDataStream.

So writing to the stream on a little endian platform and then reading on
big endian would have swapped the bytes of your 16 bit member.

regards,

Andre



More information about the Qt-interest-old mailing list