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

Vincent Cai wcai at cypress.com
Thu Oct 13 11:08:55 CEST 2011


You are right, thanks so much!

-----Original Message-----
From: Andre Haupt [mailto:andre at bitwigglers.org]
Sent: 2011年10月13日 17:05
To: Vincent Cai
Cc: Andre Haupt; Samuel Gaist; Qt-interest
Subject: Re: [Qt-interest] how to output a user defined struct data to datastream?

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

This message and any attachments may contain Cypress (or its subsidiaries) confidential information. If it has been received in error, please advise the sender and immediately delete this message.


More information about the Qt-interest-old mailing list