Solved [Solved] How i can set parameters for childs?
-
Hi,
i have for example a following code:
ColumnLayout { id: columnLayout1 anchors.fill: parent spacing: 0 RowLayout { id: sectionMiddle spacing:parent.spacing ColumnLayout { id: sectionABCE spacing:parent.spacing RowLayout { id: sectionAB spacing:parent.spacing ColumnLayout { id: sectionA width: 54 height: 300 spacing:parent.spacing .....
How i can set a spacing for all children of a parent? Is possible? Or must i all of them set manually? Sorry for my English, I'm just learning. I hope, you understand me. :)
Thank you for help
-
-
@raven-worx
Do you think something like that?:function setChildrenParameters(object,parameters){ for(var i=0;i<parameters.length;i++){ if(child[parameters[0][i]]!=undefined){ child[parameters[0][i]]=parameters[1][i]; } } if(child.children.length>0){ for(var i=0;i<child.children.length;i++){ setChildrenParameters(child.children[i],parameters); } } } ColumnLayout { id: columnLayout1 anchors.fill: parent Component.onCompleted: { setChildrenParameters(this,[["spacing"],[0]]); }
-
@Prochy said in How i can set parameters for childs?:
Do you think something like that?
Yes.
I did some corrections:function setChildrenParameters(object,parameters) { for(var i=0;i<parameters.length;i++) { if(child[parameters[i][0]] != undefined) { child[parameters[i][0]]=parameters[i][1]; } } for(var i=0;i<child.children.length;i++) { setChildrenParameters(child.children[i],parameters); } }
-
@raven-worx
Yes, thank you for help and corrections.