Raw data conversion using (?) QByteArray
Solved
General and Desktop
-
-
You're almost there:
char raw_bytes[4] = {0x00, 0x00, 0xff, 0xff}; QByteArray byte_array = QByteArray::fromRawData(raw_bytes, 4); QDataStream in(&byte_array, QIODevice::ReadOnly); quint16 value; in >> value; // First 2 bytes, gives 0 in >> value; // Second 2 bytes, 65535
-
Hi!
char raw_bytes[4] = {0x00, 0x00, 0xff, 0xff}; QByteArray byte_array = QByteArray::fromRawData(raw_bytes, 4); QDataStream stream(byte_array); int result; stream >> result; qDebug() << result; // 65535
Cheers!
-
@kshegunov Ninja!