PDA

View Full Version : Storing hex in QBytearray, extracting it and converting it to decimal



TheIndependentAquarius
18th March 2016, 11:22
int dd = 0xA5;

QByteArray p;
p.push_back (0xA5);
qDebug () << "SOP: " << (int)p[0];


This results in -91 whereas 0xA5 stands for 165 in decimal.

How to store hex in QBytearray, extract it and convert it to decimal?

Added after 11 minutes:

This helped: http://www.qtcentre.org/threads/29598-Extracting-int-values-from-QByteArray?p=139019#post139019

Also, I could have casted it to unsigned char.

d_stranz
18th March 2016, 20:15
Yep. 256 - 91 = 165 last time I checked.