I would like to convert QVector<double>
to QBytearray
, and I have no idea on how to do this.
I tried this but the program crashes:
QVector<double> vec;
QByteArray arr = QByteArray::fromRawData(reinterpret_cast<const char*>(vec),vec.size());
for(int i = 0; i< vec.size(); i++)
arr.append(reinterpret_cast<const char*>(vec.data(&numberOfData),sizeof(double));
Can someone tell me how to do it properly?