[Qt-interest] Rendering artefacts when moving QGraphicsItems

Andre Somers andre at familiesomers.nl
Wed Apr 21 10:51:09 CEST 2010


On 20-4-2010 17:43, Andre Somers wrote:
> 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.
>    
I managed to solve the issue with a bit of a hack. Since the 
QGraphicsItem subclass also inherits from
QObject, I can emit a signal if the item is moved using a 
reimplementation of
QGraphicsItem::itemChange that I had in there anyway. I then connect 
this signal to the QGraphicsView
viewports update() slot. That gets rid of the junk.

Since I don't expect a huge amount of dragging around components on my 
view, this hack is acceptable for now. I would have prefered to find a 
real fix, of course, especially since the small testcase did not have 
this issue.

> 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.
>    
I tried a simple version just for testing. The result was:
* the trails were not fixed; instead they now also appeared for the main 
graphics item itself, making it look worse.
* all interaction that I had in place with the item was messed up.

I think QGraphicsItemGroup is nice for the case in the documentation, 
but not for this use case.

Thanks for the help Jason and Sean!

André




More information about the Qt-interest-old mailing list