how to convert qbytearray to hex array
Solved
General and Desktop
-
-
@Liny said in how to convert qbytearray to hex array:
test[0] = 0x30;
0x30 is a string representation of a binary value in hexadecimal.
[EDIT]
QByteArray is an array of char.
So test[31] is printed as ascii char 1To print hex values you can do:
qdebug << hex << "test[1] = "<< test[1]; -
@Liny
I forgot the cast !
qDebug() <<hex<< "test[1] = "<< (uint8_t)test[1];Note the unsigned int.
casting to int, uint or uint8_t don't print the same result:test[0] = 0x90; qDebug() <<hex<< "test[0] = "<< (int)test[0] << (uint)test[0]<< (uint8_t)test[0];
test[0] = -70 ffffff90 90
-