how to add column and give actions for a respective row in a existing table view from database
Unsolved
General and Desktop
-
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).
I want to
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.
2. differentiate every even/odd row by a separate color.
Here is my main.qml file for your reference.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 > 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 { } } }
the execution is like this...
Thanks in Advance.