PDA

View Full Version : QGraphicsItem::ItemIgnoresTransformations and redrawing artifacts



JeDi
22nd October 2012, 12:38
Hi,

I am implementing a graphics view to display a motion captured point trace. I use a QGraphicsPathItem for the trace, and a QGraphicsEllipseItem to indicate the current position. The user has to be able to zoom and pan the view, but the current position indicator has to stay the same size in pixels.

So I decided to use the QGraphicsItem::ItemIgnoresTransformations flag on the ellipse so it ignores the scaling of the view. It works as intended, but on Mac OS there are redrawing artifacts (the ellipse stays on screen until a full redraw). I'm not sure why the artifacts are not present in Windows, but my guess is that this is an issue with the boundingRect of the item which misbehaves in combination with the QGraphicsItem::ItemIgnoresTransformations flag.

Is this a know issue? Are there any good workarounds? Maybe creating a custom implementation for the "non-scalable dot", ignoring the scaling in the boundingRect method, is the best way? Are there better ways to draw dots instead of a QGraphicsEllipseItem?

Greetings,
JeDi

wysota
23rd October 2012, 23:11
If it is your custom item, please show its boundingRect() and paint() implementations.

JeDi
24th October 2012, 12:24
No, I am using a standard QGraphicsEllipseItem. That's why I think this behavior is strange. I could of course write a custom item and implement my own correct boundingRect function, but because I used a standard item I expected it to render without artifacts.

wysota
24th October 2012, 12:54
Could you show us some example code that demonstrates the problem?

JeDi
21st November 2012, 14:05
I'm sorry, I forgot to add this topic to my watch list and didn't see this reply...

I don't have any simple example code for now, but it is a scene with standard ellipse items with the ignore transforms option set. Because I used meters as my units, the scene is zoomed in a lot to fit on the screen (meters to pixels).

I am now using QT5, and because there pens are not cosmetic by default anymore (when using a width of 0) I had to convert all pens (mostly of reference lines I draw) to explicitly be cosmetic. There are no artifacts anymore, and they are also gone when I compile in QT 4.8.3.

So the artifacts were maybe not caused by the ellipses, but by the default pens I used, in combination with a large zoom factor?

Edit Actually, I just compiled with QT 4.8.1, and the artefacts are still present. They are completely gone in QT5 beta2 though.