Solved children vs childrenRect
-
Hi All,
I have a scenario where i need to bind the parent item's height to its children height , sample code for understandingItem { width: 300 height: children.height // or childrenRect.height Item{ ............. } Item{ ........... } }
I need to know which is the best way to bind, either to use children.height or childrenRect.height and please explain the reason for the choice.
Any help is appreciated.
Thanks!
-
Is this for real? Have you even tried it?
children
is a list of items. It does not even have aheight
property!So obviously, the answer is:
childrenRect.height
. -
And that's not the best way to accomplish this.
You should use positioners like
Row
orColumn
or layouts likeColumnLayout
orRowLayout
.
If you don't want that for some reason, you should set the implicit size of your container from the implicit size of your items.
I have yet to see a legit use-case ofchildrenRect
.I guess you should better define what you want from a higher level point of view.
Item { width: 300 Item{ ............. } Item{ ........... } }
Do you want both child item to be side by side? Stacked on top of eachother?
Do you want to position them manually? -
@sierdzio , I was using children.height in my project. As you mentioned, I dig deeper and its a wrong approach which i have used in my project sometime.
Thanks for the info.
-
@GrecKo , I want all my child items to be placed side by side.
-
@Vinoth-Rajendran4 said in children vs childrenRect:
@GrecKo , I want all my child items to be placed side by side.
In that case you should use Row or RowLayout.