Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. how to add column and give actions for a respective row in a existing table view from database
Forum Updated to NodeBB v4.3 + New Features

how to add column and give actions for a respective row in a existing table view from database

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 112 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.
  • P Offline
    P Offline
    postbox
    wrote on last edited by postbox
    #1

    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...
    Screenshot from 2023-03-25 17-02-51.png

    Thanks in Advance.

    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