QDataStream doesn't work as expected
I have this sample code:
Code:
quint32 tag;
tag = 0x00;
newDataSrteam
->setByteOrder
(QDataStream::LittleEndian);
int i = 0;
while(i++<10)
{
ba.clear();
*newDataSrteam << (quint32)tag++;
printf("%s\n", ba.toHex().data());
}
and running I get the following output:
Code:
00000000
0000000001000000
303030303030303002000000
30303030303030300200000003000000
3030303030303030020000000300000004000000
303030303030303002000000030000000400000005000000
33303330333033303330333033303330303230303030303006000000
3330333033303330333033303330333030323030303030300600000007000000
333033303330333033303330333033303032303030303030060000000700000008000000
33303330333033303330333033303330303230303030303006000000070000000800000009000000
I wonder what is wrong with my code...
what is happening? It seem that be is never cleared...
thanks
Re: QDataStream doesn't work as expected
you'd better to seek the current postion before to read data.