Answer the question
In order to leave comments, you need to log in
How to convert string like 0x0102 0x304f to QByteArray?
Hello.
We have a QString like "0x0102 0x304f" and so on, it needs to be converted to a QByteArray. So that it
contains qarr[0] = 0x01
qarr[0] = 0x02
qarr[0] = 0x30
qarr[0] = 0x4f
Answer the question
In order to leave comments, you need to log in
QString str = "0x0102 0x304f";
str.remove("0x");
str.remove(" ");
QByteArray arr = str.toLatin1();
QByteArray qarr = QByteArray::fromHex(arr);
What do you need a dock for?
QString str;
QByteArray array;
array.append(str);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question