问题
Is it possible to move up/down the visual items in order to change its overlapping? currently, the child hides its parent, but i'd like to have the reverse, i.e. the parent hides the child. Maybe some properties exists?
回答1:
Yes it's possible. You will need to change the z
property of the involved items. According to the documentation:
Sets the stacking order of sibling items. By default the stacking order is 0.
Items with a higher stacking value are drawn on top of siblings with a lower stacking order. Items with the same stacking value are drawn bottom up in the order they appear. Items with a negative stacking value are drawn under their parent's content.
Hence, you only need to set z
property of children to a negative value:
import QtQuick 2.4
Rectangle {
width:800
height: 480
color: "yellow"
// opacity: 0.5 (1)
Rectangle{
width: 100
height: 100
color:"red"
z:-1
}
}
In this example the inner Rectangle
is not visible since its z
property has a negative value. Uncomment the opacity
assignament of the outer Rectangle
in (1) to see it.
来源:https://stackoverflow.com/questions/31527916/change-order-of-visible-items