I am receiving a QByteArray from UDP Socket. The QByteArray is of 52 elements each containing values from 0 to 9 - A to F. Now, I want to convert this QByteArray into a short int array of 13 elements such that first 4 elements of the QByteArray are stored in first element of short int array.
Eg. QByteArray = (002400AB12CD) -> ShortINT = [0024,00AB,12CD]
I have tried concatenating 4 elements and then convert them to Short INT.
You can use
QByteArray::data()andQByteArray::constData()to access pointer to stored data and use c cast or reinterp_cast to cast specific type. Also you need to know endianness of data is it big-endian or little endian.Qt 4 does not have
_betypes. You can useqFromBigEndianorqbswapto swap bytes.