QByteArray to QString containing hex data
Unsolved
General and Desktop
-
Hello guys,
I am trying to convert a QByteArray to QString. The array consists of hex data.
QByteArray ba;
ba[0] = 01;
ba[1] = 80;
ba[2] = 7F;
ba[3] = 52;I'm trying to convert the above array to QString as "01807F52". I tried using QByteArray::number, but facing issue with 7F.
Can someone give me a hint how to achieve this.
Any help is greatly appreciated.--Narayanan K
-
QString hex(ba.toHex());
should work?
PS:
Note, however, that:ba[0] = 01; ba[1] = 80; ba[2] = 7F; ba[3] = 52;
should rather be:
ba[0] = 0x01; ba[1] = 0x80; ba[2] = 0x7F; ba[3] = 0x52;