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

Weighted layout behavior is not documented

XMLWordPrintable

    • fe66830abe869d7e7244c77779c9ff7aa51037c3 (qt/qtdeclarative/dev) 463d16de5d41647267008fdd4a6460b8c00f5434 (qt/qtdeclarative/6.2)

      When preferredWidth/Height is set with fillWidth/Height, layouts use preferredWidth/Height as a weight when laying out elements. For example this reserves 2/3 for the red and 1/3 for the blue rectangle:

          RowLayout {
              anchors.fill: parent
      
              Rectangle {
                  Layout.fillWidth: true
                  Layout.fillHeight: true
                  Layout.preferredWidth: 100
                  color: "red"
              }
              Rectangle {
                  Layout.fillWidth: true
                  Layout.fillHeight: true
                  Layout.preferredWidth: 50
                  color: "blue"
              }
          }
      

      This behavior does not seem to be mentioned in the documentation:

      https://doc.qt.io/qt-5/qml-qtquick-layouts-layout.html#fillWidth-attached-prop
      https://doc.qt.io/qt-5/qml-qtquick-layouts-layout.html#preferredWidth-attached-prop

        For Gerrit Dashboard: QTBUG-98127
        # Subject Branch Project Status CR V

            kkohne Kai Köhne
            poikelin Joni Poikelin
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes