QByteArray 转int
int bytesToInt(QByteArray bytes) {
int addr = bytes[0] & 0x000000FF;
addr |= ((bytes[1] << 8) & 0x0000FF00);
addr |= ((bytes[2] << 16) & 0x00FF0000);
addr |= ((bytes[3] << 24) & 0xFF000000);
return addr;
}
int转QByteArray
QByteArray intToByte(int number)
{
QByteArray abyte0;
abyte0.resize(4);
abyte0[0] = (uchar) (0x000000ff & number);
abyte0[1] = (uchar) ((0x0000ff00 & number) >> 8);
abyte0[2] = (uchar) ((0x00ff0000 & number) >> 16);
abyte0[3] = (uchar) ((0xff000000 & number) >> 24);
return abyte0;
}