Important: Please read the Qt Code of Conduct -

Repeater resize problem

  • Hello,
    I have rectangle and in this rectangle i have label. This rectangle height resizing with label contentHeight.
    My codes here for this rectangle.

    I trying to do this for repeater with same codes but not working.
    Codes here

    I tried get contentHeight of label but i getting 0 and i see text's without rectangle.
    How can i fix this problem ? How can i resize hight of rectangle in repeater?
    Thank you.

  • @jondoe hi
    this works as expected

    import QtQuick 2.12
    import QtQuick.Window 2.12
    import QtQuick.Controls 2.12
    import QtQuick.Layouts 1.12
    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
        property real msize: 12
        onClicked: msize = 25
        anchors.right: parent.right
        text: "change size"
            anchors.fill: parent
                model: 10
                Rectangle {
                    id: annenbe
                    width: 200
                    height: testo.contentHeight
                    border.width: 1
                    color: "red"
                    onHeightChanged: console.log("size->", testo.contentHeight)
                        id: testo
                        color: "#ffffff"
                        text: "text"
                        wrapMode: Text.WrapAnywhere
                        anchors.horizontalCenter: parent.horizontalCenter
                        anchors.fill: parent
                        font.weight: Font.DemiBold
                        font.pixelSize: msize

  • @lelev Not worked.
    Your code working when u writing text yourself but i getting text from url so i guess i need change size after get text.

  • annenbe.height = testo.contentHeight i fixed with this code in onHeightChaned and worked. Thank you @LeLev

Log in to reply