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

TableView size is 0

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.15.0
    • None
    • All

    Description

      The following code will not work as expected:

       

      TableView {
       id: table
       anchors.fill: parent
       
       model: TableModel {
          TableModelColumn { display: "col1" }
          TableModelColumn { display: "col2" }
          TableModelColumn { display: "col3" }
          rows: [
              { col1: "value1", col2: "value2", col3: "value3" },
              { col1: "value4", col2: "value5", col3: "value6" },
              { col1: "value7", col2: "value8", col3: "value9" },
          ] 
       }
       delegate: Rectangle {
          //implicitWidth: 100
          implicitHeight: 30
          Text {
              text: model.display
              anchors.fill: parent
          }
       }
       columnWidthProvider: function(column) { console.log(table.width / 3); return table.width / 3; }
       onWidthChanged: console.log("table.width: " + table.width)
       }
      

       

      Output:

      qml: 0
      qml: 0
      qml: 0
      qml: table.width: 400

       

      the table width always is 0 when the columnWidthProvider function is created so there is no way to calculate it dynamically other than to make it statically what is not always convenient. I expect that this construction will create a binding and so columnWidthProvider will be updated when table.width will be changed but not.

       

      Attachments

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

        Activity

          People

            srutledg Shawn Rutledge
            folibis ruslan
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes