Layout.fillwidth returns 0



  • Hi,

    I am using a GridLayout with 2 columns, and I want to get the width of the second column which Layout.fillwidth is true, however it returns 0.

    Is there any way to determine the width if Layout.fillwidth is set to true? or any other way to implement such where i can determine the second column's width?

      GridLayout {
        id: infoGrid
        Layout.fillWidth: true
    
        columns: 2
        columnSpacing: 20
        rowSpacing: 5
    
        Text {
          text: qsTr("Server :")
        }
       Text {
          Layout.fillWidth: true
          text: qsTr("Server name")
        }
      }
    

    Please advise, thanks!



  • Sorry for bumping this, because still I can't figure this out. Thanks.



  • Width of the second column is the width of the "Server name" element. If you are trying to get it in the Component.onCompleted, it won't do much because the layout is not calculated yet.



  • @devel Thanks for the reply.

    I wanted to get the whole width not just the painted width because i want to scroll the text if the paintedWidth is greater than its column width.



  • That's probably the implicitWidth of the largest item.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.