Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Repeater resize problem

Repeater resize problem

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 782 Views
  • 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.
  • jondoeJ Offline
    jondoeJ Offline
    jondoe
    wrote on last edited by jondoe
    #1

    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ïO 1 Reply Last reply
    0
    • jondoeJ 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ïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by ODБOï
      #2

      @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"
                      }
                  }
              }
          }
      }
      
      
      
      jondoeJ 1 Reply Last reply
      0
      • ODБOïO 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"
                        }
                    }
                }
            }
        }
        
        
        
        jondoeJ Offline
        jondoeJ Offline
        jondoe
        wrote on last edited by
        #3

        @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.

        jondoeJ 1 Reply Last reply
        0
        • jondoeJ jondoe

          @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.

          jondoeJ Offline
          jondoeJ Offline
          jondoe
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved