Description
The ZIndex
property of the GraphicsItem
class represents the z-order of the graphics item within its parent. This property determines the rendering order of items, where items with higher ZIndex
values are drawn on top of those with lower values. It is a floating-point value, allowing for fine-grained control over the stacking order of items.
Usage
To set the ZIndex
of a GraphicsItem
, simply assign a float
value to it. Higher values will render the item above others with lower values. This is useful for managing the visual layering of items in a scene.
Example
// Create a new GraphicsItem
GraphicsItem item = new GraphicsItem();
// Set the ZIndex to ensure it is rendered above other items
item.ZIndex = 5.0f;
// Check the current ZIndex
float currentZIndex = item.ZIndex;
// Output: 5.0
// This indicates the item will be rendered above items with a lower ZIndex.