You are not logged in.

Dear visitor, welcome to If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.


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