Sunday, August 16, 2009

Trobadour knowledge about QGraphicsScene

If you do not want your QGraphicsView to repaint itself totally do not delete QGraphicsItems without removing them from the QGraphicsScene first.

6 comments:

Unknown said...

I think that I got my project error...
why I haven't guessed it before ?

James Smith said...

Someone better tell the WorldClock guys because it still locks Plasma hard at 100%.

Anonymous said...

shouldn't this be the standard behaviour anyway?
first remove, then delete
or move + change settings (to reuse the object)
at least i designed it that way for a qt project some time ago

Albert Astals Cid said...

@James: Having a quick look at worldclock plasmoid i think the reason for it's slowness is a different one

@anon: Why so i have to remove it before deleting? I mean in the developer mind it's "Ok, i don't need this item anymore, so let's delete it", and the thing is that it works, just it's much slower and i sincerely don't see a reason for that.

Gof said...

The reason is that in the ~QGraphicsViewItem, the virtuals functions such as the boundingRect are not avaliable anymore.
So the graphics view doesn't know what to update and then has to update everything.

Anonymous said...

@Albert Astals Cid
well in real live when someone dies you also have to notify the parents (when they still live) and remove the person out of the registers, don't you?