Solved Anchor to item which has height depending on children.
-
I want to anchor
ProcessDisplay
toSystemInformationDisplay
like this:Window { id: root visible: true width: 840 height: 480 title: qsTr("System Monitor") SystemInformationDisplay{ id: systemInformationDisplay width: root.width } ProcessDisplay{ anchors.top: systemInformationDisplay.bottom id: processDisplay width: root.width height: root.height - systemInformationDisplayHeight; } }
This does not work because I don't provide the heigth in
SystemInformationDisplay
.The problem is I have to calculate the height inside the Item
SystemInformationDisplay
.I do it inside lie this:
SystemInformationDisplay.qml:
Item { id: root height: (8 + sysinfo.coreUtilizationsInPercent.length) * elementHeight readonly property int elementWidth: root.width readonly property int elementHeight: 20 property int fontSize: elementHeight - 8 SystemInformation{ id: sysinfo } //.... }
In short. How can I anchor to a Item which only after startup i know its height?
Is it necessary to calculate the height from outside the widget?
-
hi
@sandro4912 said in Anchor to item which has height depending on children.:in short. How can I anchor to a Item which only after startup i know its height?
there is nothing special to do
@sandro4912 said in Anchor to item which has height depending on children.:
Is it necessary to calculate the height from outside the widget?
no, you can do it inside your component as you did in your example
The anchors should be refreshed as soon as SystemInformationDisplay's height is calculatedthe probleme must come frome something else,
ProcessDisplay{ anchors.top: systemInformationDisplay.bottom id: processDisplay width: root.width height: root.height - systemInformationDisplayHeight; // < }
what is systemInformationDisplayHeight should it be systemInformationDisplay.height ?
-
@LeLev said in Anchor to item which has height depending on children.:
what is systemInformationDisplayHeight should it be systemInformationDisplay.height ?
Thats the problem. Very nasty that I could not see that. Now it works perfect. Thank you alot for spotting that.