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

Setting Loader to inactive doesn't reset its width/height

    XMLWordPrintable

Details

    Description

      Loading a Component in a Loader will set the Loader's size to the item's height (if not specified otherwise). Setting the Loader to inactive later will not reset its height but it will still occupy the space, albeit being empty.

      import QtQuick 2.0
      import QtQuick.Controls 1.1
      
      Rectangle {
          id: rect
          width: 800
          height: 600
      
          property Component testRect: Rectangle {
              width: 200
              height: 200
              color: "#f90"
          }
      
          Column {
              Loader {
                  id: testLoader
                  sourceComponent: rect.testRect
                  active: false
              }
      
              Button {
                  text: testLoader.active ? "Disable" : "Enable"
                  onClicked: testLoader.active = !testLoader.active
              }
          }
      }
      

      Press the button, observe the orange rectangle appears and moves the button downwards. Press the button again, the orange rectangle disappears but its space is still occupied.

      height: item ? item.height : 0
      

      works around the issue.

      Attachments

        Issue Links

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

          Activity

            People

              aalpert Alan Alpert
              broulik Kai Uwe Broulik
              Votes:
              3 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes