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 column names not showing.
Qt 6.11 is out! See what's new in the release blog

Tableview column names not showing.

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 374 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.
  • F Offline
    F Offline
    Fakhr
    wrote on last edited by
    #1

    Hi, So I want to create a table similar to the one in the picture.
    1.PNG

    After some searching I decided to use tableview. My code is given below.

    import QtQuick 2.15
    import QtQuick.Controls 2.15
    import Qt.labs.qmlmodels 1.0
    Item {
        width: 1126
        height: 800
    
        Rectangle {
            id: rectangle
            color: "#ffffff"
            anchors.fill: parent
            anchors.rightMargin: 0
            anchors.bottomMargin: 0
            anchors.leftMargin: 0
            anchors.topMargin: 0
    
            TableView {
                anchors.fill: parent
                columnSpacing: 1
                rowSpacing: 1
                clip: true
    
                model: TableModel {
                    TableModelColumn { display: "customer" }
                    TableModelColumn { display: "address" }
                    TableModelColumn { display: "mobile" }
                    TableModelColumn { display: "email" }
                    TableModelColumn { display: "city" }
                    TableModelColumn { display: "state" }
                    TableModelColumn { display: "country" }
    
                    rows: [
                        {
                            "customer": "h",
                            "address": "down",
                            "mobile": "34556",
                            "email": "ty@gmail.com",
                            "city": "new york",
                            "state": "new york",
                            "country": "USA"
    
                        },
                        {
                            "customer": "h",
                            "address": "down",
                            "mobile": "34556",
                            "email": "ty@gmail.com",
                            "city": "new york",
                            "state": "new york",
                            "country": "USA"
                        },
                        {
                            "customer": "h",
                            "address": "down",
                            "mobile": "34556",
                            "email": "ty@gmail.com",
                            "city": "new york",
                            "state": "new york",
                            "country": "USA"
                        }
                    ]
                }
    
                delegate: Rectangle {
                    implicitHeight: 50
                    implicitWidth: 100
                    border.width: 1
    
                    Text {
                        text: display
                        anchors.centerIn: parent
                    }
                }
            }
        }
    }
    

    The first problem is that I can't see the column name. Secondly I wanted to ask that i'm using pyside2 as the main business language, and i'm going to be connecting to a database all the data in this table will be filled from the database, so I just wanted to confirm whether tableview is the correct choice in this scenario, or should I use something else.

    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