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
Forum Updated to NodeBB v4.3 + New Features

how to create multiple rows of different size with rowlayout

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 3 Posters 1.3k 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.
  • A Offline
    A Offline
    Ahti
    wrote on 13 Jun 2019, 18:50 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
    • F Offline
      F Offline
      fcarney
      wrote on 13 Jun 2019, 22:56 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.

      A 1 Reply Last reply 14 Jun 2019, 06:44
      3
      • P Offline
        P Offline
        Pradeep P N
        wrote on 14 Jun 2019, 03:41 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
        • F fcarney
          13 Jun 2019, 22:56

          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"
                          }
                      }
                  }
              }
          
          A Offline
          A Offline
          Ahti
          wrote on 14 Jun 2019, 06:44 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

          P 1 Reply Last reply 14 Jun 2019, 07:30
          0
          • A Ahti
            14 Jun 2019, 06:44

            @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 ?

            P Offline
            P Offline
            Pradeep P N
            wrote on 14 Jun 2019, 07:30 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

            1/5

            13 Jun 2019, 18:50

            • Login

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