PDA

View Full Version : QByteArray to int array



Trixon
21st February 2012, 17:30
Hello,
I have a question about convertion QByteArray to int array.
Here is example:


QByteArray bin = file.readAll();
//"bin" has a {10101010101}
//for ex.: bin[0] returns 1, but it is not integer and I need to convert this to int array
//I want to have result int: n {the same}

ChrisW67
21st February 2012, 22:34
Your information and question are unclear.

You have a QByteArray. It contains some number (n) of bytes: possibly characters, possibly not. You say the first byte is 1. Is that the value 0x01 or the character '1' (0x31)?

You want to get these n bytes into an int[]. sizeof(int) is probably 4, are you expecting n/4 elements in your int array, or n?