문제

I have a QByteArray i create manually:

QByteArray hexArray(QByteArray::fromHex("495676"));

If this was encoded ASCII it would be "IVv". If I want to get a single byte of data from that array. I can do that like this:

qDebug() << messageToBeSent_raw[0];

However, that outputs I, which is correct but I would like to get 49. What I'm looking for is an equivalent of the QByteArray::toHex() just for a single byte. Is there a way to do it?

도움이 되었습니까?

해결책

You can use QString::number.

qDebug() << QString::number(hexArray[0], 16);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top