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

QML Layout does not scale children correctly when they are initially hidden

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P2: Important
    • None
    • 5.5.1
    • Quick: Layouts
    • None
    • PC MinGW QT5.5.1

    Description

      I have a RowLayout with multiple children which I want evenly distributed over the available space. Some of these are initially hidden and will be shown at runtime.

      Example scenario:
      2 rectangles, 'blue' one initially hidden. Clicking on the 'red' one makes the 'blue' rectangle visible.

      Expected: Both rectangles should then evenly use the space.
      Actual: Only 'red' rectangle is visible + spacing. 'Blue' rectangle remains hidden.

      RowLayout {
          anchors.fill: parent
      
          Rectangle {
              id: rect1
              Layout.fillWidth: true
              Layout.fillHeight: true
              color: "red"
      
              MouseArea
              {
                  anchors.fill: parent
                  onClicked:
                  {
                      rect2.visible = !rect2.visible
                  }
              }
          }
      
          Rectangle {
              id: rect2
              Layout.fillWidth: true
              Layout.fillHeight: true
              color: "blue"
              visible: false
      
          }
      }
      

      Setting preferredWidth on both as suggested here https://bugreports.qt.io/browse/QTBUG-43261 does not help.

      Attached is example code, click on red rectangle to try make the blue one visible (which won't work).

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              smd Jan Arve
              rvdk rvdk
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes