[Qt-interest] Rendering artefacts when moving QGraphicsItems

Sean Harmer sean.harmer at maps-technology.com
Wed Apr 21 13:57:25 CEST 2010


On Wednesday 21 Apr 2010 09:51:09 Andre Somers wrote:
> 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!

No problem. If you can extract your graphics item(s) into a test app which 
does show the problem I don't mind taking a look at it. Not promising I would 
be able to solve it though! ;-)

Good luck with your project,

Sean



More information about the Qt-interest-old mailing list