PDA

View Full Version : goal: image always on top of polygone



myrabbitrules
23rd February 2011, 17:25
Hi!

I draw a polygone and an image onto a QGraphicsScene which is displayed using a QGraphicsView.
I want the image to always be on top of the polygone. I guess this could be accomplished by always drawing the image after drawing the polygone (i draw repeatedly ever 30ms).
However I would then have to remove my image, and draw it again, as this is what I do with the polygone. However this sounds bad. At the moment I simply use setPos() to move the image which is why the polygone is always (except for the very first time) on top.

How can I make my image always appear on top of my polygone?

Thanks for any advice.

SixDegrees
23rd February 2011, 21:09
GraphicsView/Scene/Item supports z-ordering. You have to explicitly set the layer your items are placed in; once placed, that's where they'll stay, and they will be draw from lowest to highest numbered layer. See the documentation for more details.