You are not logged in.

Dear visitor, welcome to QtForum.org. 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.

1

Saturday, April 4th 2009, 6:53pm

Convert ByteArray to Integer

I want to convert Byte array values to Integers and check for some specific value.

My byte array suppose contains bytes like -> FF 2 3 25 10 etc. How do I check if the value is FF or 10 etc. ?
An example which failed ->


Source code

1
2
3
4
5
6
7
8
9
10
11
12
QByteArray ba; 

int i ; 
for( i = 0; i < ba.size(); i++ ) 


{ 
if (ba[i] == 255){ 
//Do Something 

} 
}



This gives the error


C:/Users/vinay/Prog/telnetpro/telnetpro/telnetpro.cpp:61: error: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:


The error is for the line [/i]

if (ba[i] == 255){[/i]



?(

2

Sunday, April 5th 2009, 8:58am

Does...

Source code

1
if (ba[i] == '\xFF'){

...help?