QVector append but empty



  • 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



  • 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).



  • With your current code, there is no reason it shouldn't work.

    Can you give us some more code ? Where does it not work ?



  • What does return @qDebug() <<l_return;@ ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.