Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QByteArray and QDataStream
Chobin last edited by
I'd like to use QDataStream class to format data that I receive as QByteArray. I wrote this code:
DataBuff.append(1); DataBuff.append(2); QDataStream ds(&DataBuff, QIODevice::ReadOnly); ds>>data;
I expecte as result of my code data=258, but the real result is a bad number.
Could someone help me?
Many thanks in advance for your support.
Eeli K last edited by
@Chobin Have you debugged this with a breakpoint? You can see inside the objects, maybe it helps.
This works perfectly. What is the output you got when you printed ds ? It prints 258 only. Which platform you tried ?
stryga42 last edited by
What number do you get? 513? Would indicate Big-Endian / Little Endian mixup.