Max / min in QML

I would like to set the height of the element. This should be the height of the highest child.

Is there something like:

Parent { height : max (child1.height, child2.height) } 

Alternatively something like:

 Parent { height : stretchToChildren } 
+4
source share
2 answers

Math.max() is variational (takes arbitrarily many arguments).

Depending on the actual location, it may be possible to use the Item.childrenRect property.

+11
source
 Item { width: childrenRect.width // width is now 100 height: childrenRect.height // height is now 100 Rectangle { width: 100 height: 100 } } 

Here is an example how to work with childRect

-one
source

Source: https://habr.com/ru/post/1494776/


All Articles