0

What is the best way to convert a double array (double*) to a QByteArray ?

I have the size of the array. I thought of converting each double to a QByteArray and then append all the arrays to a big QByteArray.

For the other way, well maybe parse the data to many QByteArrays (one for each double) and convert them to double.

I don't know which QByteArray method to use for an efficient parsing ?

Thanks

Kirell
  • 9,228
  • 4
  • 46
  • 61

1 Answers1

3

If you have double* da and size of that array s you may use the following:

QByteArray::fromRawData(reinterpret_cast<const char*>(da),s*sizeof(double))
Mohammad Kanan
  • 4,452
  • 10
  • 23
  • 47
Raiv
  • 5,731
  • 1
  • 33
  • 51