Вопрос

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