You are not logged in.


Tuesday, October 9th 2012, 7:05am

How to parse a QString or QByteArray


I want to parse a QString or QByteArray, get some data, apply logical operation and return back to QByteArray again. Let me give an example, for instance, I have a QString "/SFFA0F". I want to get 0F from this string as an integer of hexadecimal number, apply some logic operations on this number (for example AND with 08 and obtain 08) and again create the string as "/SFFA08". How can I do that? I have tried toAscii(), toInt(), toHex() commands, but I guess I miss something. Thanks in advance,




  • "shiny" is female

Posts: 23

Location: India

Occupation: software engineer

  • Send private message


Thursday, October 11th 2012, 11:39am

QString S1="/SFFA0F";
QString S2 = S1.right(2); //S2="0F"
int N1= S1.toInt(0, 16);
//apply logical opertaion on N1
S2 = QString::number(N1);
S1.replace("0F", S2);

i think it will help you

Similar threads