[Qt-interest] Rendering artefacts when moving QGraphicsItems

Andre Somers andre at familiesomers.nl
Tue Apr 20 17:43:27 CEST 2010


On 20-4-2010 12:28, Sean Harmer wrote:
> Hi,
>
> On Tuesday 20 Apr 2010 10:41:27 Andre Somers wrote:
>    
>> 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.
>>      
> Are you able to make a small test case that we can try to reproduce the
> problem with please?
>
>    
The small test case I just made, shows none of the problems that I have 
in the real case :-( I must be overlooking some crusial difference, but 
I can't find it so far. I set all the same flags on the items, the view 
and the scene, as far as I can see.

The GraphicsItemGroup suggestion isn't  what I need. I don't want *all* 
events to be merged into one (as it would do according to the docs). 
Also, my attempt at creating one based on what I have now failed so far, 
and refactoring to try this suggestion seems a bit too much work at this 
time.

André




More information about the Qt-interest-old mailing list