Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Repeater resize problem

    QML and Qt Quick
    2
    4
    345
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • jondoe
      jondoe last edited by jondoe

      Hello,
      I have rectangle and in this rectangle i have label. This rectangle height resizing with label contentHeight.
      My codes here for this rectangle.
      https://pastebin.com/eeaJm1E1

      I trying to do this for repeater with same codes but not working.
      Codes here
      https://pastebin.com/NtrYnQTC

      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.

      ODБOï 1 Reply Last reply Reply Quote 0
      • ODБOï
        ODБOï @jondoe last edited by ODБOï

        @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
        
        Button{
            onClicked: msize = 25
            anchors.right: parent.right
            text: "change size"
        }
            ColumnLayout{
                anchors.fill: parent
                Repeater{
                    model: 10
                    Rectangle {
                        id: annenbe
                        width: 200
                        height: testo.contentHeight
                        border.width: 1
                        color: "red"
                        onHeightChanged: console.log("size->", testo.contentHeight)
        
                        Text{
                            id: testo
                            color: "#ffffff"
                            text: "text"
                            wrapMode: Text.WrapAnywhere
                            anchors.horizontalCenter: parent.horizontalCenter
                            anchors.fill: parent
                            font.weight: Font.DemiBold
                            font.pixelSize: msize
                            font.family: "Arial"
                        }
                    }
                }
            }
        }
        
        
        
        jondoe 1 Reply Last reply Reply Quote 0
        • jondoe
          jondoe @ODБOï last edited by

          @lelev Not worked. http://prntscr.com/or8aqr
          Your code working when u writing text yourself but i getting text from url so i guess i need change size after get text.

          jondoe 1 Reply Last reply Reply Quote 0
          • jondoe
            jondoe @jondoe last edited by

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

            1 Reply Last reply Reply Quote 0
            • First post
              Last post