[Qt-interest] Rendering artefacts when moving QGraphicsItems

Andre Somers andre at familiesomers.nl
Tue Apr 20 11:41:27 CEST 2010


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é

-------------- next part --------------
A non-text attachment was scrubbed...
Name: renderbug.png
Type: image/png
Size: 17418 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100420/7f447114/attachment.png 


More information about the Qt-interest-old mailing list