PDA

View Full Version : QGraphicsScene Z Ordering



bruceariggs
27th September 2011, 15:41
I have a bunch of QGraphicsItem's that can be added and removed from my scene by my users at any given time.

In the code, certain QGraphicsItem child classes that I derived have a setZValue() in their constructor that sort items the way I would want them to be sorted

Ship = 1.0 (always on top)
Waypoints = 0.9
Targets, Markpoints = 0.8
RangeRings, ErrorEllipse = 0.5
Waypoint Lines = 0.4
Map = 0.0 (Always on bottom)

Yet, as the users add items to and from the scene, the Z sorting seems to be ignored! It just sorts by insertion order!

How do I get the QGraphicsScene to actually LOOK at the Z values I've set for these items and USE them? Is there a refresh function or something I'm suppose to call?

Added after 10 minutes:

Nevermind, I got it fixed.

I removed the setZValue() out of the constructor, and put it down to where I call addItem() in the scene, and it seems to work now. Whatever.