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

StackLayout does not set the correct size for a dynamically created element

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.15.0 RC2
    • None
    • Ubuntu 20.04
      Qt 5.15
    • All

    Description

      The test code:

       

      import QtQuick 2.15
      import QtQuick.Window 2.15
      import QtQuick.Layouts 1.15
      import QtQuick.Controls 2.12
      Window {
       width: 800
       height: 600
      visible: true
      Component {
       id: stackItemComponent
      Rectangle {
       color: Qt.rgba(Math.random(),Math.random(),Math.random(),1)
       Layout.fillWidth: true
       Layout.fillHeight: true
       Text {
       text: "Hello world"
       anchors.centerIn: parent
       }
       }
       }
      MouseArea {
       anchors.fill: parent
      onClicked: {
       var item = stackItemComponent.createObject(stackLayout)
       stackLayout.children.push(item)
       }
       }
      StackLayout {
       id: stackLayout
       anchors.fill: parent
       }
      }
      

       

      The item that dynamically created and added to the StackLayout has no size. But resizing the Window and probably the StackLayout fixes that i.e. the created item suddenly acquires its true size.

       

      Attachments

        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
            folibis ruslan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes