Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. TableView's RowHeightProvider issue

TableView's RowHeightProvider issue

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qt6qml typestableviewpyside6
1 Posts 1 Posters 333 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LS-KS
    wrote on last edited by
    #1

    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-prop

    In 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:

    Bildschirmfoto 2023-07-30 um 21.44.24.png

    Can anybody explain what I'm missing?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved