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. New TableView - dynamic columns possible?
Forum Updated to NodeBB v4.3 + New Features

New TableView - dynamic columns possible?

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 156 Views 1 Watching
  • 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.
  • S Offline
    S Offline
    SeDi
    wrote on 2 Aug 2019, 20:37 last edited by
    #1

    Hi,
    I still use the (now deprecated) QtQuick.Controls 1.4 for TableView in order to achieve dynamic columns. For this I am taking the resources approach (see below), but it seems impossible in the new TableView. For starters, TableViewColumn doesn't seem to exist.

    Any idea on how to achieve that? Or is it better to stick with the old TableView for now?

    TableView {
             id: dynTable
            model: sceneLoader ? sceneLoader.loaderModel : 0
            resources:
            {
                var temp = []
                var columnComponent
                for(var i=0; i<roleList.length; i++) {
                    var role  = roleList[i]
                    var columnHeaderName = //whatever
                            columnComponent = columnComponentText
                    if (columnComponent) {
                        temp.push(columnComponent.createObject(
                                      dynTable, {
                                          "role": role,
                                          "title": columnHeaderName,
                                          "width": //whatever
                                          "visible": true
                                      }))
                    }
                    
                }
                
                return temp
            }
    

    As for the Component:

    Component {
            id: columnComponentText
            
            TableViewColumn { 
                delegate: Item {
                    clip: true
                    Rectangle {
                        id: backColorRect
                        // whatever
                    }
                    Text {
                        id: textDelegate
                        anchors.fill: parent
                        text: //whatever
                        clip: true
                    }
                }
            }
        }
    

    In the new (Qt 5.13) TableView

    1 Reply Last reply
    0

    1/1

    2 Aug 2019, 20:37

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved