Miss Engineer
28th August 2014, 03:28
Hello,
I want to create a packet of data from a collection of bits and bytes and later store in a binary file.. I am using QDataStream as I figured it is the only way to serialise my data.
QByteArray dataset=new QByteArray();
QDataStream outtopacket =new QDataStream(dataset, QIODevice::WriteOnly);
Now if I stream a bit:
bool mode = false;
*outtopacket<<mode;
and then stream a byte
quint8 data = 15;
*outtopacket<<data;
how is it going to deal with the bit? Is it going to pad it with zeros? Will the next data streamed into the packet occupy the next empty bit in QByteArray?
Any better way to serialize my data?
I want to create a packet of data from a collection of bits and bytes and later store in a binary file.. I am using QDataStream as I figured it is the only way to serialise my data.
QByteArray dataset=new QByteArray();
QDataStream outtopacket =new QDataStream(dataset, QIODevice::WriteOnly);
Now if I stream a bit:
bool mode = false;
*outtopacket<<mode;
and then stream a byte
quint8 data = 15;
*outtopacket<<data;
how is it going to deal with the bit? Is it going to pad it with zeros? Will the next data streamed into the packet occupy the next empty bit in QByteArray?
Any better way to serialize my data?