Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-93179

Allow aligning column widths across separate GridLayouts

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • None
    • Quick: Layouts
    • None

    Description

      When you have a bunch of "sections" represented by e.g. GroupBoxes to create a sort of form layout, you generally want to align the first column:

      import QtQuick
      import QtQuick.Controls
      import QtQuick.Layouts
      
      ApplicationWindow {
          width: 300
          height: 300
          visible: true
          ColumnLayout {
              anchors.fill: parent
              GroupBox {
                  title: qsTr("Dialog properties")
                  Layout.fillWidth: true
                  GridLayout {
                      columns: 2
                      anchors.fill: parent
                      Label {
                          text: qsTr("modality")
                          Layout.alignment: Qt.AlignTop
                          Layout.minimumWidth: ApplicationWindow.window.width * 0.2
                          Layout.maximumWidth: ApplicationWindow.window.width * 0.2
                      }
                      CheckBox {
                      }
                  }
              }
              GroupBox {
                  title: qsTr("FileDialog properties")
                  Layout.fillWidth: true
                  GridLayout {
                      columns: 2
                      anchors.fill: parent
                      Label {
                          text: qsTr("acceptLabel")
                          Layout.minimumWidth: ApplicationWindow.window.width * 0.2
                          Layout.maximumWidth: ApplicationWindow.window.width * 0.2
                      }
                      TextField {
                          id: acceptLabelTextField
                          text: qsTr("OK")
                      }
                  }
              }
          }
      }
      

      The first column should use the largest implicit width (here I hard-coded it for the sake of the example). That could be done via e.g. QTBUG-44078 or some other API.

      The second column should take the remaining space, but the items within it shouldn't fill; they should be left-aligned.

      Expected:

      Actual:

      Attachments

        Issue Links

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              mitch_curtis Mitch Curtis
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: