PDA

View Full Version : Values not being appended in a QList



Kapil
20th April 2006, 12:47
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..


void CGUITileType::displayRLC(int numRLC)
{
m_pCRectRLC = new Q3CanvasRectangle(xPoint,yPoint,width,height,m_pCa nvas);
m_pCRectRLC->show();

RLCRecList.append(m_pCRectRLC);

m_pCLineRLCHorizontal = new Q3CanvasLine*[8];
m_pCLineConnectHrzRLC = new Q3CanvasLine*[8];

for(i=0;i<8;i++)
{
m_pCLineRLCHorizontal[i] = new Q3CanvasLine(m_pCanvas);
m_pCLineRLCHorizontal[i]->setPoints(h_xxPoint,h_xyPoint,h_yxPoint,h_yyPoint) ;
m_pCLineRLCHorizontal[i]->show();

RLCHorizontalLineList.append(m_pCLineRLCHorizontal[i]);
}


m_pCLineRLCVertical = new Q3CanvasLine*[4];

for(i=0;i<4;i++)
{
m_pCLineRLCVertical[i] = new Q3CanvasLine(m_pCanvas);
m_pCLineRLCVertical[i]->setPoints(v_xxPoint[i],v_xyPoint,v_yxPoint,v_yyPoint);
m_pCLineRLCVertical[i]->show();

RLCVerticalLineList.append(m_pCLineRLCVertical[i]);

}

}



and the .h (header file) is


class CGUITileType : public Q3CanvasView
{
private:
QList<Q3CanvasItem *> RLCHorizontalLineList;
QList<Q3CanvasItem *> RLCVerticalLineList;

};



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

zlatko
20th April 2006, 17:02
Strange solution ..imho this way is better


for(i=0;i<8;i++)
{
Q3CanvasLine *line = new Q3CanvasLine(m_pCanvas);
line->setPoints(h_xxPoint,h_xyPoint,h_yxPoint,h_yyPoint) ;
line->show();
RLCHorizontalLineList.append(line);
}

Kapil
21st April 2006, 04:53
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

Kapil
21st April 2006, 08:29
Hi..

the Problem is solved...

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

Thank you...

Kapil

jpn
21st April 2006, 08:32
It could be nice (or even useful for someone in the future) to hear what was the problem.. ;)

Kapil
21st April 2006, 10:20
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 :p

take care...

Kapil