<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[how to add column and give actions for a respective row in a existing table view from database]]></title><description><![CDATA[<p dir="auto">Hi all, i have been doing practice in creating table view. what i did is created a database in aws, and add table there. The contents in that table is reflecting here in a execution(i attached below).<br />
I want to<br />
1.extend the table by adding columns and write actions for each row like download/delete something like that which i can download/delete the entire row by clicking that.<br />
2. differentiate every even/odd row by a separate color.<br />
Here is my main.qml file for your reference.</p>
<pre><code>import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.4
import QtQuick.Layouts 1.15
Window {
    visible: true
    width: 640
    height: 480
    title: qsTr("QSqlQueryModel - TableView")


    TableView {
        id: tableView
        topMargin: 35
        columnWidthProvider: function (column) { return 120; }
        rowHeightProvider: function (column) { return 60; }
        anchors.fill: parent

        ScrollBar.horizontal: ScrollBar{}
        ScrollBar.vertical: ScrollBar{}
        clip: true

        model: MysqlModel

        // Table Header

        Row {
            id: columnsHeader
            y: tableView.contentY
            Repeater {
                model: tableView.columns &gt; 0 ? tableView.columns : 1

                Rectangle {
                   width:   tableView.columnWidthProvider(modelData)
                   height:  35
                   border.width: 1
                   color: "#ccc"

                   Text {
                       anchors.centerIn: parent
                       //verticalAlignment: Text.AlignVCenter
                       text: MysqlModel.headerData(modelData, Qt.Horizontal)
                       font.pixelSize: 15
                       padding: 15
                   }
                }
            }
        }

        // Table Body

        delegate: Rectangle {
            id: header
            y: 35
            border.width: 1
            TextArea{
                text: display 
                anchors.fill: parent
                //anchors.margins: 5
                color: 'black'
                font.pixelSize: 15
                verticalAlignment: Text.AlignVCenter
                wrapMode: TextArea.WordWrap
            }
        }

        
        ScrollIndicator.horizontal: ScrollIndicator { }
        ScrollIndicator.vertical: ScrollIndicator { }
    }
}
</code></pre>
<p dir="auto">the execution is like this...<br />
<img src="https://ddgobkiprc33d.cloudfront.net/26711c38-8eb6-44ba-961f-8641df82c20b.png" alt="Screenshot from 2023-03-25 17-02-51.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Thanks in Advance.</p>
]]></description><link>https://forum.qt.io/topic/143885/how-to-add-column-and-give-actions-for-a-respective-row-in-a-existing-table-view-from-database</link><generator>RSS for Node</generator><lastBuildDate>Mon, 17 Aug 2026 16:21:39 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/143885.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 25 Mar 2023 11:48:17 GMT</pubDate><ttl>60</ttl></channel></rss>