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. Is there a way to have subheader on a TableView?
QtWS25 Last Chance

Is there a way to have subheader on a TableView?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
tableviewtableviewcolumn
1 Posts 1 Posters 480 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.
  • N Offline
    N Offline
    Nmaster88
    wrote on 15 Jul 2019, 11:09 last edited by Nmaster88
    #1

    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

    1 Reply Last reply
    0

    1/1

    15 Jul 2019, 11:09

    • Login

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