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

TableView size is 0

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 5.15.0
    • Fix Version/s: None
    • Labels:
      None
    • Platform/s:
      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

            Assignee:
            srutledg Shawn Rutledge
            Reporter:
            folibis ruslan
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes