Logo Search packages:      
Sourcecode: qt4-x11 version File versions

void QGraphicsItem::setZValue ( qreal  z  )  [inherited]

Sets the Z-value, or the elevation, of the item, to z. The elevation decides the stacking order of sibling (neighboring) items. An item of high Z-value will be drawn on top of an item with a lower Z-value if they share the same parent item. In addition, children of an item will always be drawn on top of the parent, regardless of the child's Z-value. Sibling items that share the same Z-value will be drawn in an undefined order, although the order will stay the same for as long as the items live.

graphicsview-zorder.png

Children of different parents are stacked according to the Z-value of each item's ancestor item which is an immediate child of the two items' closest common ancestor. For example, a robot item might define a torso item as the parent of a head item, two arm items, and two upper-leg items. The upper-leg items would each be parents of one lower-leg item, and each lower-leg item would be parents of one foot item. The stacking order of the feet is the same as the stacking order of each foot's ancestor that is an immediate child of the two feet's common ancestor (i.e., the torso item); so the feet are stacked in the same order as the upper-leg items, regardless of each foot's Z-value.

The Z-value does not affect the item's size in any way.

The default Z-value is 0.

See also:
zValue()

Definition at line 2581 of file qgraphicsitem.cpp.

Referenced by MainWindow::bringToFront(), DiagramScene::mousePressEvent(), MainWindow::sendToBack(), QGraphicsScene::setActiveWindow(), and ImageItem::updateItemPosition().

{
    qreal newZ = qreal(itemChange(ItemZValueChange, double(z)).toDouble());
    if (newZ == d_ptr->z)
        return;
    d_ptr->z = z;
    d_ptr->fullUpdateHelper();
    itemChange(ItemZValueHasChanged, double(newZ));
}


Generated by  Doxygen 1.6.0   Back to index