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

TextEdit does not calculate the implicitWidth in a designer use case

    XMLWordPrintable

Details

    Description

      A TextEdit which has no width but was quested for the implicitWidth and got then a text does never recalculate with or implicitWidth. This resulted in a 0 sized TextEdit inside the QtQuickDesigner.

      • simple example
        import QtQuick 2.6
        import QtQuick.Window 2.2
        
        Window {
            visible: true
            width: 640
            height: 100
            title: qsTr("Hello World")
            property Item sizedRect
            Rectangle {
                id: rect
                anchors.fill: parent
                Component.onCompleted: {
                    var myComponent = Qt.createComponent("TestText.qml")
                    var textEdit = myComponent.createObject(rect)
                    textEdit.text = "short"
                    print(textEdit.implicitWidth)
                    print("################")
                    textEdit.text = "in contrast to short this is long"
                    print(textEdit.implicitWidth)
                    print(textEdit.width)
                    textEdit.text = "and this not that long"
                    print(textEdit.implicitWidth)
                    print(textEdit.width)
                    sizedRect = textEdit
                }
        
            }
            Column {
                y: 50
                Rectangle {
                    color: "red"
                    height: 10
                    width: sizedRect.width
                }
                Rectangle {
                    color: "blue"
                    height: 10
                    width: sizedRect.implicitWidth
                }
            }
        }
        
      • output:
        qml: 25
        qml: ################
        qml: 25
        qml: 25
        qml: 25
        qml: 25
        

      Attachments

        Issue Links

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

          Activity

            People

              tjenssen Tim Jenssen
              tjenssen Tim Jenssen
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes