Int16 to QByteArray
-
Hi,
Out of curiosity, why not use QByteArray::number ?
-
@m.sue said in Int16 to QByteArray:
Hi,
withqDebug() << QByteArray::number(id,16);
you will get the four characters "2113". So it depends on what you really need.
-Michael.@SGaist
Yes I've tried that function but I'll send the byteArray with TCP to a micro controller after the transformation, so QByteArray::nummer or .setNum is not an option. -
Hi
Will the micro controller also run Qt and be able to use QDataStream ? -
@TomHoe said in Int16 to QByteArray:
didn't knew that '!' is the same as 0x21..
See http://www.ascii-code.com/
'!'
== 33 == 0x21 == 0b00100001@TomHoe said in Int16 to QByteArray:
Is there a way to rewrite it to regular hex codes ? Or does every controller understand this notation ?
Again,
'!'
== 33 == 0x21 == 0b00100001Those are different ways of displaying the same bytes. The controller does not see any "hex" or "notation"; it only sees the sequence of 0's and 1's.
I recommend you learn about how bits/bytes are stored in computer memory: http://statmath.wu.ac.at/courses/data-analysis/itdtHTML/node55.html