PDA

View Full Version : Selective highlighting of Items



Kapil
25th May 2006, 08:54
Hi...

I have a canvas on which i have created many items..
i have stored all the items in a QList, (QList <Q3CanvasItem*>).. Now i run a function where in on value specified in a file, it extracts those items and sets a pen of different color for them and then show() it... But in the output the color is not changed.. When i tried to debug and check whether is it selecting the correct items or not then yes it was returning me the right value and was moving thru the correct items... I was also updating the canvas on all chages...
I couldnt understand why is this happening..

Then i tried a different approach... i tried to extract the points of the items whose color would be changed.. and tried to create a new similar item on top of the existing item with the same coordinate set but different color.. but then in this it does not create lines at all points.. it makes for some points and for some it doesn't... i again tried to debug it and the result was positive but not seen on output..
There was also a strange problem with it... when i rerun the application, this time it highlights different items from the value set.. It picks each value but changes color of random items from that set... i couldnt understand why is it so happening....

Please help me with it...

Thanking you,

with regards,
Kapil

wysota
25th May 2006, 10:37
i have stored all the items in a QList, (QList <Q3CanvasItem*>)..
Are you aware of QCanvas::allItems()?


Now i run a function where in on value specified in a file, it extracts those items and sets a pen of different color for them and then show() it... But in the output the color is not changed..
Can we see the code?



When i tried to debug and check whether is it selecting the correct items or not then yes it was returning me the right value and was moving thru the correct items... I was also updating the canvas on all chages...
I couldnt understand why is this happening..
Did you mark those items as changed?

QCanvasItem *item;
QCanvas *canvas;
//...
canvas->setChanged(item->boundingRect());

Kapil
25th May 2006, 11:00
Are you aware of QCanvas::allItems()?

yaa.. but i had to maintain a list of different item types.. so i made a list for each set of items... allItems would have returned me all the items but i needed seperate list for each type..



Can we see the code?




Q3Canvas *m_pCanvas;
Q3CanvasLine *pLine;
QList <Q3CanvasItem*> m_globalOutYLine;

//m_globalOutYLine is filled with a canvas lines...
//lineVal is the value of the line which has to be coloured from a value set

pLine = (Q3CanvasLine*)m_globalOutYLine[lineVal];
pLine->setPen(QPen(color));
pLine->show();

m_pCanvas->update();





Did you mark those items as changed?

QCanvasItem *item;
QCanvas *canvas;
//...
canvas->setChanged(item->boundingRect());

No i didnt do so... would try to do so and see what happens..

Thank you,

with regards,
Kapil

Kapil
26th May 2006, 12:20
canvas->setChanged(item->boundingRect());


setChanged function also not helping out...
i am not able to get what can be the reason for it....

thanking you,
Kapil