[SOLVED]How to Convert between QList<double> and QByteArray
-
may be this example is correct, but the byte array it outputs is 164 bytes, suppose to be 160 bytes.
@QByteArray byteArray;
QDataStream stream(&byteArray, QIODevice::WriteOnly);QList<double> data; for(int i=0;i<20; i++){ data.append(i+0.5); } stream << data;@
And how to convert byteArray back to QList<double>?
Thanks
-
Well, just found it, Share to your guys.
QList<double> to bytearray,
@ QByteArray byteArray;
QDataStream stream(&byteArray, QIODevice::WriteOnly);QList<double> data; for(int i=0;i<20; i++){ data.append(i+0.5); } stream << data;
@
ByteArray back to QList<double>
@QList<double> data;
QDataStream stream(&byteArray, QIODevice::ReadWrite);
stream >> data;@