Greg S code works fine for me (Qt 4.6.2 and WinXP). The least significant bits of quint16 come from QByteArray [1], and the most significant bits come from QByteArray [0]. But if you want to control exactly how quint16 is built, get both bytes for the byte array and build quint16 from them:
QDataStream dataStream(yourByteArray);
quint8 byte0;
quint8 byte1;
dataStream >> byte0 >> byte1;
quint16 result = (byte0 << 8) + byte1;
user362638
source
share