PDA

View Full Version : QGraphicsItems on top of each other?



Morea
18th November 2006, 19:57
Hello. I'm writing a game and now I wonder:
If a QGraphicsItem moves so that it ends up inside of a larger QGraphicsItem, is there any easy way of making the smaller one end up on top of the larger one?

It would be very nice with a "layer order" or something. I will have 3 different items. One huge covering the entire screen (map), and some minor ontop of this(castles), and then some very small that are always displayed on top of everything else (fighters).

Or do I have to do this with the parent/child stuff? That will be hard since I don't think it will be efficient to put all child/parent connections!!! There will likely be more than 10 000 child/parent relations!

wysota
18th November 2006, 20:14
Set the "z" coordinate (QGraphicsItem::setZValue()) of the smaller item to be lower (or higher, I don't remember) than the "z" coordinate of the bigger item.

Morea
18th November 2006, 20:23
Thanks!
You really knows this stuff and the Qt guys have really thought of these things.