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

Clearing TextEdit in nested ColumnLayout within a Dialog causes other cells to stop filling

    XMLWordPrintable

Details

    Description

      Minimal example:

      import QtQuick
      import QtQuick.Controls
      import QtQuick.Layouts
      import QtQuick.Templates as T
      
      ApplicationWindow {
          width: 800
          height: 600
          title: "QTBUG-92983 - contentWidth " + control.contentWidth + " contentHeight " + control.contentHeight
          visible: true
      
          Shortcut {
              sequence: "Ctrl+Q"
              onActivated: Qt.quit()
          }
      
          Button {
              text: "Open"
              onClicked: fileDialog.open()
          }
      
          T.Dialog {
              id: control
              objectName: "dialog"
              // control.contentWidth (indirectly) refers to control.contentItem.implicitWidth
              implicitWidth: Math.max(600, control.contentWidth)
              implicitHeight: Math.max(400, control.contentHeight)
              visible: true
      
              background: Rectangle {
                  objectName: "backgroundRect"
                  color: control.palette.window
                  border.color: control.palette.dark
              }
      
              // contentItems always fill the availableWidth/Height (see QQuickControlPrivate::resizeContent())
              contentItem: ColumnLayout {
                  objectName: "fontDialogOuterColumnLayout"
                  onImplicitHeightChanged: print("implicitHeight of " + objectName + " changed: ", implicitHeight)
      
                  // Implicitly fills.
                  ColumnLayout {
                      objectName: "fontDialogInnerColumnLayout"
      
                      onImplicitHeightChanged: print("implicitHeight of " + objectName + " changed: ", implicitHeight)
      
                      TextEdit { // TextField works
                          id: styleEdit
                          objectName: "styleEdit"
                          text: "Enter style here"
                          topPadding: 0
                          bottomPadding: 0
      
                          Layout.fillWidth: true
      
                          onImplicitHeightChanged: print("implicitHeight of " + objectName + " changed: ", implicitHeight)
      
                          Button {
                              text: "x"
                              width: height
                              height: parent.height
                              anchors.right: parent.right
                              visible: styleEdit.length > 0
                              onClicked: styleEdit.clear()
                          }
                      }
                      Rectangle {
                          objectName: "dummyLayoutRect"
                          color: "transparent"
                          border.color: "darkorange"
      
                          Label {
                              text: "This should always fill"
                              anchors.centerIn: parent
                          }
      
                          Layout.fillWidth: true
                          Layout.fillHeight: true
                      }
                  }
              }
          }
      }
      

      The original code can be seen here:

      https://codereview.qt-project.org/c/qt/qtquickcontrols2/+/338951/14/src/quickdialogs2/quickdialogs2quickimpl/qml/%252BFusion/FontDialog.qml#113

      It uses a GridLayout, but ColumnLayout reproduces it too.

      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
              mitch_curtis Mitch Curtis
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes