TableView's RowHeightProvider issue
-
Hey,
I'm not sure if I fully understood the docs regarding the RowHeightProvider:
https://doc.qt.io/qt-6/qml-qtquick-tableview.html#rowHeightProvider-propIn my PySide6 I'm Using A Table View for Eventlogging.
As long as the Text is short, everything is fine. but sometimes I have to display a warning with a little more text. In that case I can't figure out how to provide the correct rowHeight:What I tried:
At first I tried to use the 'isRowLoaded' property like this:
isRowLoaded? -50 : -1
because the docs said that if the value is negative, the height would be calculated on the content. But this doesn't work.
Somewhere in the Qt ecosystem I found a solution which is based on the row's children (can't find it anymore).
I changed it a bit to loop over all children to find out the max contentHeight. This doesn't have any effect:TableView { id: eventLogView width: parent.width height: parent.height model: eventModel clip: true columnWidthProvider: function (column) { if (column === 0) return 100 if (column === 1) return 150 if (column === 2) return eventLogView.width - 250 } rowHeightProvider: function (row) { if (isRowLoaded(row)) { var item = loadedRow(row); var contentHeight = 0; for (var i = 0; i < item.children.length; i++) { if (item.children[i].contentHeight > contentHeight) { contentHeight = item.children[i].contentHeight; } } return contentHeight + 10; } else { return -1; } } delegate: DelegateChooser{ role: "column" DelegateChoice { roleValue: 0 EventDelegate { displayText: model.text isTime: true } } DelegateChoice { roleValue: 1 EventDelegate { displayText: model.text isSource: true } } DelegateChoice { roleValue: 2 EventDelegate { displayText: model.text isEvent: true } } } }
As long the text fits into two lines, everything is fine. But with more lines the result looks like this:
Can anybody explain what I'm missing?