QVector append but empty
-
wrote on 23 Aug 2011, 12:24 last edited by
Hello,
a have written a return method, which should return a QVector object. This is just for testing purpose.
Anyway, the QPoint object contains correct values.
But when I make a appen the entries are erroneous.. My QVector has enough space, according to the l_length parameter.. But those are empty..@
QVector< QPoint > MyClass::GetPointList( int l_length )
{
QVector< QPoint > l_return;for( int i = 0; i < l_length; i++ ) {
QPoint t(i, i+10);
l_return.append(t);
}
return l_return;
}
@Do I make anything wrong in that piece of code?
Thank you in advise
Huck
-
wrote on 23 Aug 2011, 12:31 last edited by
No, looks fine to me, even though it could be made more efficient by initializing your vector with the correct length (saves some copies when the vector is growing).
-
wrote on 23 Aug 2011, 12:32 last edited by
With your current code, there is no reason it shouldn't work.
Can you give us some more code ? Where does it not work ?
1/4