Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QVector append but empty

QVector append but empty

Scheduled Pinned Locked Moved General and Desktop
4 Posts 4 Posters 3.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    huckfinn
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • O Offline
        O Offline
        octal
        wrote on last edited by
        #3

        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 Reply Last reply
        0
        • S Offline
          S Offline
          Scylla
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved