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

Dynamic resizing problem with GridLayout, RowLayout, ColumnLayout holding items which have a Layout.fillWidth or Layout.fillHeight property

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.6
    • None

    Description

      Hello!

      Such a piece of code produces, possibly, a bug:

      import QtQuick 2.6
      import QtQuick.Window 2.2
      import QtQuick.Layouts 1.3
      
      Window {
          visible: true
          width: 640
          height: 480
          title: qsTr("Hello World")
      
          GridLayout {
              rowSpacing: 50
              columnSpacing: rowSpacing
              columns: 1
              rows: 1
              anchors { fill:parent; margins: rowSpacing; }
      
              Rectangle {
                  color: "gray"
                  Layout.alignment: Qt.AlignCenter | Qt.AlignVCenter
                  Layout.maximumHeight: 100
                  Layout.maximumWidth: 100
                  Layout.fillWidth: true
                  Layout.fillHeight: true
              }
          }
      }
      
      

      If you do not use dynamic resizing, everything is alright. If you try to resize the window in this example, you might have the outcome like on the screenshots.
      It is expected that content's dimensions are decreased to 0, however, they are frozen on some small number at some point.
      To workaround this problem you may read layout width or height properties at the moment of scaling to zero size:

          GridLayout {
              // Added id
              id: layout
      
              rowSpacing: 50
              columnSpacing: rowSpacing
              columns: 1
              rows: 1
              anchors { fill:parent; margins: rowSpacing; }
      
              Rectangle {
                  color: "gray"
                  Layout.alignment: Qt.AlignCenter | Qt.AlignVCenter
                  // Added conditions
                  Layout.maximumHeight: layout.height <= 0 ? 0 : 100
                  Layout.maximumWidth: layout.width <= 0 ? 0 : 100
      
                  Layout.fillWidth: true
                  Layout.fillHeight: true
              }
          }
      

      Attachments

        Issue Links

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

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              yaroslavd Anonymous (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes