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. how to create multiple rows of different size with rowlayout
Qt 6.11 is out! See what's new in the release blog

how to create multiple rows of different size with rowlayout

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 3 Posters 1.6k Views
  • 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.
  • AhtiA Offline
    AhtiA Offline
    Ahti
    wrote on last edited by
    #1

    I want to have multiple rows each one having different number of controls. I am using RowLayout for that ? here is my code so far:

    My Code:

     RowLayout {
            anchors.fill: parent
            spacing: 5
    
            ColumnLayout {
                Layout.preferredHeight: parent.height
                Layout.preferredWidth: parent.width
    
                Text {
                    Layout.preferredWidth: 200
                    Layout.preferredHeight: 20
                    text: qsTr("label: ")
                    Layout.alignment: Qt.AlignRight
                }
            }
    
            ColumnLayout {
                Layout.preferredHeight: parent.height
                Layout.preferredWidth: parent.width
    
                Slider {
                    id: slider_0
                    Layout.preferredWidth: 300
                    Layout.preferredHeight: 40
    
                    minimumValue: 0
                    maximumValue: 100
                    value: 0
                    stepSize: 1.0                
    
                    Text {
                        text: "0"
                        anchors.centerIn: slider_0
                        font.pixelSize: 25
                    }
                }
            }
        }
    

    This is what I want:

    0_1560451763291_qml layout.PNG

    Please help.

    what is a signature ?? Lol

    1 Reply Last reply
    0
    • fcarneyF Offline
      fcarneyF Offline
      fcarney
      wrote on last edited by
      #2

      I think from here you can probably figure out control6.

          ColumnLayout {
              id: all
              anchors.fill: parent
              RowLayout {
                  Layout.fillWidth: true
                  Layout.fillHeight: true
                  Layout.alignment: Qt.AlignHCenter
                  Label {
                      id: label1
                      Layout.preferredWidth: 300
                      color: "red"
                      text: "label1"
                  }
                  ColumnLayout {
                      id: controls1
      
                      Rectangle {
                          Layout.preferredWidth: 300
                          Layout.preferredHeight: 40
                          color: "blue"
                      }
                  }
              }
              RowLayout {
                  Layout.fillWidth: true
                  Layout.fillHeight: true
                  Layout.alignment: Qt.AlignHCenter
                  Label {
                      id: label2
                      Layout.preferredWidth: 300
                      color: "red"
                      text: "label2"
                  }
                  ColumnLayout {
                      id: controls2
                      Rectangle {
                          Layout.preferredWidth: 300
                          Layout.preferredHeight: 40
                          color: "blue"
                      }
                      Rectangle {
                          Layout.preferredWidth: 300
                          Layout.preferredHeight: 40
                          color: "blue"
                      }
                  }
              }
              RowLayout {
                  Layout.fillWidth: true
                  Layout.fillHeight: true
                  Layout.alignment: Qt.AlignHCenter
                  Label {
                      id: label3
                      Layout.preferredWidth: 300
                      color: "red"
                      text: "label3"
                  }
                  ColumnLayout {
                      id: controls3
                      Rectangle {
                          Layout.preferredWidth: 300
                          Layout.preferredHeight: 40
                          color: "blue"
                      }
                      Rectangle {
                          Layout.preferredWidth: 300
                          Layout.preferredHeight: 40
                          color: "blue"
                      }
                  }
              }
          }
      

      C++ is a perfectly valid school of magic.

      AhtiA 1 Reply Last reply
      3
      • Pradeep P NP Offline
        Pradeep P NP Offline
        Pradeep P N
        wrote on last edited by
        #3

        Hi @Ahti

        Prefer using Layout's inside the Layout with proper spacing & Layout.properties

        All the best.

        Pradeep Nimbalkar.
        Upvote the answer(s) that helped you to solve the issue...
        Keep code clean.

        1 Reply Last reply
        2
        • fcarneyF fcarney

          I think from here you can probably figure out control6.

              ColumnLayout {
                  id: all
                  anchors.fill: parent
                  RowLayout {
                      Layout.fillWidth: true
                      Layout.fillHeight: true
                      Layout.alignment: Qt.AlignHCenter
                      Label {
                          id: label1
                          Layout.preferredWidth: 300
                          color: "red"
                          text: "label1"
                      }
                      ColumnLayout {
                          id: controls1
          
                          Rectangle {
                              Layout.preferredWidth: 300
                              Layout.preferredHeight: 40
                              color: "blue"
                          }
                      }
                  }
                  RowLayout {
                      Layout.fillWidth: true
                      Layout.fillHeight: true
                      Layout.alignment: Qt.AlignHCenter
                      Label {
                          id: label2
                          Layout.preferredWidth: 300
                          color: "red"
                          text: "label2"
                      }
                      ColumnLayout {
                          id: controls2
                          Rectangle {
                              Layout.preferredWidth: 300
                              Layout.preferredHeight: 40
                              color: "blue"
                          }
                          Rectangle {
                              Layout.preferredWidth: 300
                              Layout.preferredHeight: 40
                              color: "blue"
                          }
                      }
                  }
                  RowLayout {
                      Layout.fillWidth: true
                      Layout.fillHeight: true
                      Layout.alignment: Qt.AlignHCenter
                      Label {
                          id: label3
                          Layout.preferredWidth: 300
                          color: "red"
                          text: "label3"
                      }
                      ColumnLayout {
                          id: controls3
                          Rectangle {
                              Layout.preferredWidth: 300
                              Layout.preferredHeight: 40
                              color: "blue"
                          }
                          Rectangle {
                              Layout.preferredWidth: 300
                              Layout.preferredHeight: 40
                              color: "blue"
                          }
                      }
                  }
              }
          
          AhtiA Offline
          AhtiA Offline
          Ahti
          wrote on last edited by Ahti
          #4

          @fcarney @Pradeep-P-N What about GridLayout would it be better to use it instead of rowlayout ? if yes how would you go about doing so ?

          what is a signature ?? Lol

          Pradeep P NP 1 Reply Last reply
          0
          • AhtiA Ahti

            @fcarney @Pradeep-P-N What about GridLayout would it be better to use it instead of rowlayout ? if yes how would you go about doing so ?

            Pradeep P NP Offline
            Pradeep P NP Offline
            Pradeep P N
            wrote on last edited by
            #5

            @Ahti
            As per your GUI image i thinks the Row & Column Layouts should be fine.

            Pradeep Nimbalkar.
            Upvote the answer(s) that helped you to solve the issue...
            Keep code clean.

            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