Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Solved Problem with positioning elements in Column Layout

    QML and Qt Quick
    2
    3
    442
    Loading More Posts
    • 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
      Pyroxar last edited by Pyroxar

      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

      E 2 Replies Last reply Reply Quote 0
      • E
        Eeli K @Pyroxar last edited by

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

        Item {Layout.fillHeight: true}
        
        1 Reply Last reply Reply Quote 0
        • E
          Eeli K @Pyroxar last edited by

          @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
          
          1 Reply Last reply Reply Quote 1
          • First post
            Last post