[Qt-interest] Rendering artefacts when moving QGraphicsItems

Jason H scorp1us at yahoo.com
Tue Apr 20 17:18:13 CEST 2010


Have you tried QGraphicsItemGroup? It sounds like it overlaps your solution, no pun intended.





----- Original Message ----
From: Andre Somers <andre at familiesomers.nl>
To: Qt-interest <qt-interest at trolltech.com>
Sent: Tue, April 20, 2010 5:41:27 AM
Subject: Re: [Qt-interest] Rendering artefacts when moving QGraphicsItems

On 24-3-2010 11:50, Andre Somers wrote:
> Hi,
> 
> I noticed what I think is a regression in Qt 4.6.?. At least, I did not notice this effect in Qt 4.5. I am using Qt 4.6.2 on Windows XP.
> 
> I have a situation where I have some QGraphicsRectItems that have some child items that are partly outside the bounds of the original item. When I move around the item using drag & drop, I often get rendering artefacts in the sense that the parts of the child items that are outside the parent item are not properly erased. This leaves a 'trail' of leftovers all over the scene if I drag the item around a bit. When the graphics view redraws, the artifacts disapear. Note that the parent item does not leave a trail.
> 
> I have reimplemented the boundingRect method to contain the child items ( I thought that this would be automatic ), but that did not help. Could somebody suggest what I might be doing wrong here?
> 
> André
> 
I am still having this issue. I have attached a screenshot showing the rendering issues I am running into.

The first issue is marked with red in the image: the trails of items after dragging the item around the view. The second issue is marked in purple: te selection rect does not completely coincide with the rect of the item itself.

The item is a subclass of QGraphicsRectItem, which has the little colored, partly overlapping rects (also QGraphicsRectItem subclasses) and the texts next to these blocks as child items.

As a try to fix it, I created a QRect that encompasses all the bounding rects of all these parts, and used that as the bounding rect. Of course, this bounding rect change is announced by calling prepareGeometryChange() on the item.

Does anyone have any tips on what I'm doing wrong here? Again: I did not see these issues in Qt 4.5.

André


      





More information about the Qt-interest-old mailing list