如何叠加QGraphicsWidget
how to overlay QGraphicsWidgets
我想将 2 个 QGraphicsWidgets 一个叠加在另一个之上。
有办法吗?
理想情况下,我想要像 QStackedLayout 这样的东西,但这只是为 QWidgets 定义的
谢谢!
QGraphicsWidget
也继承了 QGraphicsItem
,因此您可以使用默认方法来覆盖项目:更改 z-value
.
void QGraphicsItem::setZValue ( qreal z )
Sets the Z-value of the item to z. The Z value decides the stacking
order of sibling (neighboring) items. A sibling item of high Z value
will always be drawn on top of another sibling item with a lower Z
value. If you restore the Z value, the item's insertion order will
decide its stacking order. The Z-value does not affect the item's size
in any way. The default Z-value is 0.
我想将 2 个 QGraphicsWidgets 一个叠加在另一个之上。
有办法吗?
理想情况下,我想要像 QStackedLayout 这样的东西,但这只是为 QWidgets 定义的
谢谢!
QGraphicsWidget
也继承了 QGraphicsItem
,因此您可以使用默认方法来覆盖项目:更改 z-value
.
void QGraphicsItem::setZValue ( qreal z )
Sets the Z-value of the item to z. The Z value decides the stacking order of sibling (neighboring) items. A sibling item of high Z value will always be drawn on top of another sibling item with a lower Z value. If you restore the Z value, the item's insertion order will decide its stacking order. The Z-value does not affect the item's size in any way. The default Z-value is 0.