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

Layout broken if one item is initially hidden

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3: Somewhat important
    • None
    • 5.6.1, 5.7.0, 5.8.0
    • Quick: Layouts
    • None
    • Linux 64bit

    Description

      If I have a layout with four visible items, each item can be hidden without a problem.
      If one of the items is initially hidden however, the layouting fails afterwards in setting an appropriate size for that item if it is about to be shown.

      Here is code to demonstrate the problem. I used the Controls 2 template from Qt Creator and changed the QML file to:

      import QtQuick 2.7
      import QtQuick.Controls 2.0
      import QtQuick.Layouts 1.1
      
      ApplicationWindow {
          visible: true
          width: 800
          height: 250
          title: qsTr("Layout Test")
      
          Column {
              RowLayout {
                  height: 200
                  width: 800
      
                  Rectangle {
                      Layout.fillHeight: true
                      Layout.fillWidth: true
      
                      visible: first.checked
                      color: "plum"
                  }
                  Rectangle {
                      Layout.fillHeight: true
                      Layout.fillWidth: true
      
                      visible: second.checked
                      color: "teal"
                  }
                  Rectangle {
                      Layout.fillHeight: true
                      Layout.fillWidth: true
      
                      visible: third.checked
                      color: "salmon"
                  }
                  Rectangle {
                      Layout.fillHeight: true
                      Layout.fillWidth: true
      
                      visible: fourth.checked
                      color: "steelblue"
                  }
              }
              RowLayout {
                  height: 50
                  width: 800
      
                  CheckBox {
                      id: first
                      checked: true
                      text: "Show First"
                  }
                  CheckBox {
                      id: second
                      checked: true
                      text: "Show Second"
                  }
                  CheckBox {
                      id: third
                      checked: true // <-- Change to false to see the problem
                      text: "Show Third"
                  }
                  CheckBox {
                      id: fourth
                      checked: true
                      text: "Show Fourth"
                  }
              }
          }
      }
      

      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
              fsch Anonymous (Inactive)
              Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes