From the QByteArray class description :
float f = 0.0f; QByteArray array(reinterpret_cast<const char*>(&f), sizeof(f));
A QByteArray will be initialized with the contents of the memory of the float stored in it.
If you already have and just want to add data to it:
array.append(reinterpret_cast<const char*>(&f), sizeof(f));
Must do it.
To go the other way around, you just need to do the reverse operation:
float f2; if (array.size() >= sizeof(f2) { f2 = *reinterpret_cast<const float*>(array.data()); } else {
ereOn source share