Problem with positioning elements in Column Layout



  • I have code:

    Item {
                ColumnLayout {
                    spacing: 0
                    anchors.fill: parent
                    Rectangle{
                        Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
                        Layout.fillWidth: true
                        Layout.preferredHeight: (Screen.height*5)/8
                        color: "#E91E63"
                    }
                    Label {
                        Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
                        text: "Lorem ipsum dolor"
                        font.pixelSize: 28
                        color: "black"
                        font.bold: true
                    }
                    Label {
                        Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
                        text: "Ut auctor sem nec elit dictum semper"
                        font.pixelSize: 16
                        color: "black"
                    }
                }
            }
    

    I want that my Labels are under pink rectangle but then are at the bottom page.
    I don't know why
    http://imgur.com/a/xfqlB



  • @Pyroxar You can try adding a filler item after the labels:

    Item {Layout.fillHeight: true}
    


  • @Pyroxar Or if the previous one gave what you wanted (the empty white space which increases when the window is made larger goes under the labels, not between the rectangle and the labels), you can try this:

    ColumnLayout {
                    spacing: 0
                    //anchors.fill: parent
                    anchors.right: parent.right
                    anchors.left: parent.left
                    anchors.top: parent.top
    

Log in to reply