Tanks wysota for reply,
I have done some testing
out << true;
qDebug()<<" true value";
qDebug()<<" size"<< ba.size();
qDebug()<<" data"<< ba;
qDebug()<<" ba[0]"<< ba[0];
qDebug()<<" ba[1]"<< ba[1];
qDebug()<<" ba.toHex()"<< ba.toHex();
qDebug()<<" ba.data()"<< ba.data();
out1 << 0x01;
qDebug()<<" 0x01 value";
qDebug()<<" size"<< ba.size();
qDebug()<<" data"<< ba;
qDebug()<<" ba[0]"<< ba[0];
qDebug()<<" ba[1]"<< ba[1];
qDebug()<<" ba.toHex()"<< ba.toHex();
qDebug()<<" ba.data()"<< ba.data();
QByteArray ba;
QDataStream out(&ba, QIODevice::WriteOnly);
out << true;
qDebug()<<" true value";
qDebug()<<" size"<< ba.size();
qDebug()<<" data"<< ba;
qDebug()<<" ba[0]"<< ba[0];
qDebug()<<" ba[1]"<< ba[1];
qDebug()<<" ba.toHex()"<< ba.toHex();
qDebug()<<" ba.data()"<< ba.data();
QDataStream out1(&ba, QIODevice::WriteOnly);
out1 << 0x01;
qDebug()<<" 0x01 value";
qDebug()<<" size"<< ba.size();
qDebug()<<" data"<< ba;
qDebug()<<" ba[0]"<< ba[0];
qDebug()<<" ba[1]"<< ba[1];
qDebug()<<" ba.toHex()"<< ba.toHex();
qDebug()<<" ba.data()"<< ba.data();
To copy to clipboard, switch view to plain text mode
Output
true value
size 1
data ""
ba[0]
ba[1]
ba.toHex() "01"
ba.data()
0x01 value
size 4
data "
ba[0]
ba[1]
ba.toHex() "00000001"
ba.data()
And I have following questions:
1. Why line qDebug()<<" data"<< ba; do not display any data, how to see ones and zeros. I have used HEX format to see the data.
2. Why 0x01 value in HEX is "00000001" and true is "01" . true has less 0.
3. Why 0x01 value size is 4, why not 8, if in hex it is "00000001" ?
5. if I do out1 << 0x01; I get in HEX "00000001", what value I have to write, if i vant to get answer "01"?
The most iportant for me, is questions 5 and 1. I hope I will understand 2,3,4 after reading some more materials.
Thanks for advice.
Bookmarks