Is there a way to have subheader on a TableView?



  • I've been tasked to "try" to somehow adapt a TableView that has TableViewColumns in a way that it has header and subheaders.

    An example:
    0_1563188809265_2401d36d-f852-45ce-bbf1-b2d8ca1f5839-image.png

    As far as i know i can only do it like this:
    0_1563188877242_ee1caeff-8224-455a-adf8-dfa181cf901c-image.png

    In code i frequently do:

                        TableViewColumn {
                            id: zoneNumber
                            title: qsTr("teste")
                            horizontalAlignment: Text.AlignHCenter
                            width: col_zone_width
                            movable: false
                            resizable: false
                            delegate:
                                Rectangle {
                                    border.width: 1
                                    border.color: globals.table.borderColor
                                    color: globals.table.color
                                    height: parent.height
                                    anchors.fill: parent
                                    Text {
                                        anchors.fill: parent
                                        horizontalAlignment: Text.AlignHCenter
                                        verticalAlignment: Text.AlignVCenter
                                        color: globals.text.textColor
                                        text: (styleData.row + 1)
                                        font.bold: globals.menu.fontBold
                                        font.pointSize: globals.text.textSize
                                        font.family: robotoRegular.name
                                    }
                                }
                        }
    

    From documentation title in TableViewColumn only accepts a string.

    Then on TableView i have,

    headerDelegate: Rectangle{
        id:recHeader
        width:styleData.width+20
        height:301
        Text {
            anchors.fill:parent
            text:styleData.value
            horizontalAlignment: Text.AlignHCenter
            verticalAlignment: Text.AlignVCenter
        }
    }
    

    That way it seems impossible to do what i'm trying to achieve.

    Is there a solution for this? Using TableView or even another component?

    note: i'm using TableViewColumn from QtQuick.Controls 1.4, TableView from QtQuick 2.12