How to set padding or margin on GridLayout ...



  • I redefined GridLayout for reusable reason.
    Grid has padding, but GridLayout doesn't.
    Do you have any idea to use padding or margin on it?

    Rectangle {
      width: 250
      height: childrenRect.height
    
      MyGridLayout{
      // padding or margin : 10
        MyGridLayout{
          orientation:1
          text { text: "input" }
          textfield { }
        }
        Button { text: "OK"
          
        }
      }
    
    }
    

    MyGridLayout.qml

    GridLayout{
    	property int orientation : 0 // 0: vertical, 1: horizontal
    	property double spacing : 10
    	property double margin : 0
    
    	columns : (orientation == 0) ? 1 : 0
    	rows : (orientation == 0) ? 0 : 1
    	columnSpacing : spacing
    	rowSpacing : spacing
    
    	width : parent.width
    	height : (visible) ? childrenRect.height : 0
    	//x : margin
    	//y : margin
    	//width : parent.width - (margin * 2)
    	//height : childrenRect.height + margin * 2
    	//Layout.preferredHeight: childrenRect.height + margin
    	Layout.alignment : Qt.AlignTop
    
    	flow : (orientation == 0) ? GridLayout.LeftToRight : GridLayout.TopToBottom
    }
    
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.