Important: Please read the Qt Code of Conduct -

New TableView - dynamic columns possible?

  • 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
                var temp = []
                var columnComponent
                for(var i=0; i<roleList.length; i++) {
                    var role  = roleList[i]
                    var columnHeaderName = //whatever
                            columnComponent = columnComponentText
                    if (columnComponent) {
                                      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

Log in to reply