Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.15.0
-
None
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.