PDA

View Full Version : QVector<float> to QByteArray without programming



Naami
23rd May 2010, 13:11
Hi;
how to get a pointer of QVector<float> of char* type without programming.:rolleyes:
Thanks.

Naami
23rd May 2010, 13:26
ie, I need convert "QVector <float>" to "QBaytArray" for compression this data, after saving in file.

SixDegrees
23rd May 2010, 14:40
You can just take the address of the first member, assuming QVectors work like C++ vectors:

char* c = &(myVector[0]);

This assumes, though, that QVector behaves in such a way that doing so makes sense. It may not. If it doesn't behave itself, you'll have to loop through the array and do something similar to the above with each element.