Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Is there a way to have subheader on a TableView?

    QML and Qt Quick
    tableview tableviewcolumn
    1
    1
    310
    Loading More Posts
    • 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
      Nmaster88 last edited by Nmaster88

      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 Reply Quote 0
      • First post
        Last post