Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Convert QByteArray to QVector<qreal>
Moldy last edited by Moldy
I converted a qvector<qreal> to a QByteArray.
I did this by: QByteArray bytesArray ((const char *) someVector.constData(), someLength * 8);
I need to be able to reverse this and get a qvector<qreal> out of the qbytearray.
If additional information is need, let me know.
Some help would be very appreciated.
VRonin last edited by
that is wrong way of doing it
QByteArray bytesArray QDataStream out(&bytesArray ,QIODevice::WriteOnly); out << someVector; //saves it //////////////////////////////////////////////////////////////////// QDataStream in(bytesArray); QVector<qreal> otherVector; in >> otherVector; //load
Please note that qreal is only 99.9% safe when saving to stream and sending it around to programs built with other versions of Qt. use QVector<double> instead