PDA

View Full Version : The fastest way to communicate a Qvector<float> witrh Qvector<QpointF> ??



tonnot
2nd September 2011, 13:56
Can anybody give me a schema to do the fastest conversion betwen

QVector<float>
or float []

to-from Qvector<QPointF> ????

Thanks

yeye_olive
2nd September 2011, 14:12
QPointF being essentially a pair of floating-point numbers, it is unclear what kind of conversion you want to do. Please specify it.

wysota
2nd September 2011, 16:28
Can anybody give me a schema to do the fastest conversion betwen

QVector<float>
or float []

to-from Qvector<QPointF> ????

Thanks


QVector<float> vf;
QVector<QPointF> vp;
foreach(float f, vf) {
vp << QPointF(f,f); // or whatever else you want
}

tonnot
2nd September 2011, 18:24
And there is no way to do a mem copy operation ?
The information of origin - destiny are going to be the same 10 floats >>> 5 QfointF (in example )
Any idea ?

yeye_olive
2nd September 2011, 20:24
And there is no way to do a mem copy operation ?
The information of origin - destiny are going to be the same 10 floats >>> 5 QfointF (in example )
Any idea ?
No, you must not perform a raw memory copy. Use a loop to transform the elements as wysota suggested. I do not understand what you mean by "origin" or "destiny". Do you mean that the (2 * i)th and (2 * i + 1)th elements of the Qvector<float> should be cast to -- qreal being typedef'd to double or float depending on the architecture --, respectively, the x and y fields of the ith element of the Qvector<QPointF>?

wysota
3rd September 2011, 00:11
And there is no way to do a mem copy operation ?
The information of origin - destiny are going to be the same 10 floats >>> 5 QfointF (in example )
Any idea ?

float is a POD, QPointF is a full class. You should know what the implications are.