PDA

View Full Version : [Solved] "zIndex" in a QGraphicsScene



hickscorp
27th December 2007, 11:16
Hello people,

i have read everything i found on the Qt 4.3 doc... and i still dont understand something about items indexing in a QGraphicsView.

Let's imagine i create a QGraphicsScene, and add 20 items in it when in the visible area... i have done this test, and i have noticed that the first item added is the one behind the others, etc. Then if i scroll outside of the visible area (My Scene is bound to a view), sometimes i notice clipping, some early added items are behind the oldest... Now if i want to take the first added item (Behind the others), and bring it *visually* between item 10 and item 11: how am i supposed to do this?

Also another question: imagine i have the same example shema, and i take items 1, 3, 5, 7, 9 etc ... 19 and group them to "group1". Then i take all even items (2, 4, 6, 8 etc... 20) and add them to "group2". Will all the items from group1 become "behind" all the items from group2?

Any enlightenement about zIndexes on the QGraphics framework will be appreciated :)

Thanks a lot for your time, and Mery christmas :)
Pierre.

jpn
27th December 2007, 11:24
In short, take a look at QGraphicsItem::setZValue(). :)

hickscorp
27th December 2007, 11:31
lol man...

Thanks a lot, i have read everything on QGraphicsView and QGraphicsScene, i didnt spend enough time on QGraphicsItem... It is strange that the zIndex method is on the item, not on the scene!

Thanks again for the very fast answer :)
Pierre.