Results 1 to 6 of 6

Thread: Values not being appended in a QList

  1. #1
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Thanks
    14
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Unhappy Values not being appended in a QList

    Hi...

    I have created a set of Canvas Items and am trying to append them to a QList.. But they are not being appended and the size returned is 0..
    Here is the code for the .cpp and the .h file.. Please help me what can be the reason for it..
    Qt Code:
    1. void CGUITileType::displayRLC(int numRLC)
    2. {
    3. m_pCRectRLC = new Q3CanvasRectangle(xPoint,yPoint,width,height,m_pCanvas);
    4. m_pCRectRLC->show();
    5.  
    6. RLCRecList.append(m_pCRectRLC);
    7.  
    8. m_pCLineRLCHorizontal = new Q3CanvasLine*[8];
    9. m_pCLineConnectHrzRLC = new Q3CanvasLine*[8];
    10.  
    11. for(i=0;i<8;i++)
    12. {
    13. m_pCLineRLCHorizontal[i] = new Q3CanvasLine(m_pCanvas);
    14. m_pCLineRLCHorizontal[i]->setPoints(h_xxPoint,h_xyPoint,h_yxPoint,h_yyPoint);
    15. m_pCLineRLCHorizontal[i]->show();
    16.  
    17. RLCHorizontalLineList.append(m_pCLineRLCHorizontal[i]);
    18. }
    19.  
    20.  
    21. m_pCLineRLCVertical = new Q3CanvasLine*[4];
    22.  
    23. for(i=0;i<4;i++)
    24. {
    25. m_pCLineRLCVertical[i] = new Q3CanvasLine(m_pCanvas);
    26. m_pCLineRLCVertical[i]->setPoints(v_xxPoint[i],v_xyPoint,v_yxPoint,v_yyPoint);
    27. m_pCLineRLCVertical[i]->show();
    28.  
    29. RLCVerticalLineList.append(m_pCLineRLCVertical[i]);
    30.  
    31. }
    32.  
    33. }
    To copy to clipboard, switch view to plain text mode 

    and the .h (header file) is
    Qt Code:
    1. class CGUITileType : public Q3CanvasView
    2. {
    3. private:
    4. QList<Q3CanvasItem *> RLCHorizontalLineList;
    5. QList<Q3CanvasItem *> RLCVerticalLineList;
    6.  
    7. };
    To copy to clipboard, switch view to plain text mode 

    I have not put in the entire .cpp and the header file as it is very huge in size... i have put in the important declaration and use of the QList variables...

    Thank you...

    with regards,
    Kapil
    All you have to decide is what to do with the time that is given to you

  2. #2
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: Values not being appended in a QList

    Strange solution ..imho this way is better
    Qt Code:
    1. for(i=0;i<8;i++)
    2. {
    3. Q3CanvasLine *line = new Q3CanvasLine(m_pCanvas);
    4. line->setPoints(h_xxPoint,h_xyPoint,h_yxPoint,h_yyPoint);
    5. line->show();
    6. RLCHorizontalLineList.append(line);
    7. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by zlatko; 20th April 2006 at 17:06. Reason: em my way no correct.sorry
    a life without programming is like an empty bottle

  3. #3
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Thanks
    14
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Values not being appended in a QList

    Hi..

    Thanks for the reply.. this way also its not working.. basically its showing the size of the list to be zero.. thats strange.. while debugging i noticed that it was filling in the values but then dont know where the values are getting lost...

    kapil
    All you have to decide is what to do with the time that is given to you

  4. #4
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Thanks
    14
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Values not being appended in a QList

    Hi..

    the Problem is solved...

    I was able to find out my mistake and have solved it..

    Thank you...

    Kapil
    All you have to decide is what to do with the time that is given to you

  5. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Values not being appended in a QList

    It could be nice (or even useful for someone in the future) to hear what was the problem..
    J-P Nurmi

  6. #6
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Thanks
    14
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Values not being appended in a QList

    Hi...

    Sure...

    The problem was not with QList but was with the object creation.. u can say a more of C++ problem... I was filling up the QList using one object say obj1 but somewhere by mistake had created another object say obj2 via which i was trying to access the QList.. so it returned me a 0 size 'coz for that object (obj2) the QList was not initialized but was intialized for obj1...
    This was the error which i feel a dumb person like me would do it

    take care...

    Kapil
    All you have to decide is what to do with the time that is given to you

Similar Threads

  1. Sorting using qSort(), - if QList contains POINTERS
    By joseph in forum Qt Programming
    Replies: 13
    Last Post: 18th August 2013, 18:55
  2. QList, copy problems
    By Valheru in forum Qt Programming
    Replies: 4
    Last Post: 5th February 2010, 00:06
  3. Accessing QList Objects
    By magikalpnoi in forum Qt Programming
    Replies: 7
    Last Post: 21st September 2006, 20:43

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.