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. Show TableView header
Forum Updated to NodeBB v4.3 + New Features

Show TableView header

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 246 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.
  • M Offline
    M Offline
    Mihaill
    wrote on last edited by Mihaill
    #1

    Hi!
    How I can show header columns in TableView?

    import QtQuick 2.14
    import Qt.labs.qmlmodels 1.0
    
    TableView {
        anchors.fill: parent
        columnSpacing: 1
        rowSpacing: 1
        clip: true
    
        model: TableModel {
            TableModelColumn { display: "name" }
            TableModelColumn { display: "color" }
    
            rows: [
                {
                    "name": "cat",
                    "color": "black"
                },
                {
                    "name": "dog",
                    "color": "brown"
                },
                {
                    "name": "bird",
                    "color": "white"
                }
            ]
        }
    
        delegate: Rectangle {
            implicitWidth: 100
            implicitHeight: 50
            border.width: 1
    
            Text {
                text: display
                anchors.centerIn: parent
            }
        }
    }
    

    If use this, then in text column I see only 1 ,2 ...

    HorizontalHeaderView {
        id: horizontalHeader
        syncView: tableView
        anchors.left: tableView.left
    }
    
    1 Reply Last reply
    0
    • M Offline
      M Offline
      Mihaill
      wrote on last edited by
      #2

      It is work
      https://stackoverflow.com/questions/69366338/show-column-titles-in-horizontalheaderview

                  HorizontalHeaderView {
                      id: horizontalHeader
                      syncView: tableViewDelegatePointsChart
                      anchors.left: tableViewDelegatePointsChart.left
                      model: ["from", "to", "mid", "max", "min"]
                  }
      
      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