Change order of visible items

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Change order of visible items



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 Answer
1



Yes it's possible. You will need to change the z property of the involved items. According to the documentation:


z



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:


z


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.


Rectangle


z


opacity


Rectangle





Pay attention: z defines stacking order of sibling items only But Items with a negative stacking value are drawn under their parent's content
– folibis
Jul 21 '15 at 5:30



z


Items with a negative stacking value are drawn under their parent's content





@ folibis 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.Higher z on top... doc.qt.io/qt-5/qml-qtquick-item.html#z-prophttp://doc.qt.io/… It's the z order see documentation, it is what his looking for :)
– Mido
Jul 21 '15 at 5:37





@folibis was pointing that while your code answers the question the text is not interely correct. Add the sentence he proposed.
– BaCaRoZzo
Jul 21 '15 at 5:46





@BaCARoZzo ah ok, I didn't understand hes comment , done:)
– Mido
Jul 21 '15 at 5:48





@john Kush yes it's possible ,z is a real it takes not only 0, 1 or -1, you can always increase the z in order to hide a parent of a parent. if you want some object to be always on top per example put it's z : Infinity, ...
– Mido
Jul 21 '15 at 11:15







By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard