Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [Solved] How i can set parameters for childs?
Qt 6.11 is out! See what's new in the release blog

[Solved] How i can set parameters for childs?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
5 Posts 2 Posters 1.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Prochy
    wrote on last edited by Prochy
    #1

    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-worxR 1 Reply Last reply
    0
    • P Prochy

      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-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by raven-worx
      #2

      @Prochy
      you could implement a ("top-level") method which iterates over the item's children recursively and set your properties.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      P 1 Reply Last reply
      0
      • raven-worxR raven-worx

        @Prochy
        you could implement a ("top-level") method which iterates over the item's children recursively and set your properties.

        P Offline
        P Offline
        Prochy
        wrote on last edited by
        #3

        @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]]);
                }
        
        raven-worxR 1 Reply Last reply
        0
        • P Prochy

          @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]]);
                  }
          
          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @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);
                      }
              }
          

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          P 1 Reply Last reply
          1
          • raven-worxR raven-worx

            @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);
                        }
                }
            
            P Offline
            P Offline
            Prochy
            wrote on last edited by
            #5

            @raven-worx
            Yes, thank you for help and corrections.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved