Please nominate your Qt Champions for 2021! https://forum.qt.io/topic/132134/looking-for-the-2021-qt-champions

Custom column order in tree view



  • I want to achieve this tree view in QML:

    Screenshot

    The problem is:

    • How to have branch delegate (expand/collapse icon) as the last column
    • How to add a custom column before items, i.e. as the first column

    As far as I test, in QML TreeView:

    • Branch delegate is located as the first column, not the last one
    • Adding column to the end is straight forward, but how to add a custom column as first column?
    TreeView {
        model: cppScene.sceneModel
        // ...
        style: TreeViewStyle {
            branchDelegate: Item {
                // ...
                // ... The very first column contains branch delegate
            }
        }
        TableViewColumn {
            title: qsTr("Entities")
            role: "name"
            // ... adding column to the end is straight forward
        }
        TableViewColumn {
            // ...
            // ... adding column to the end is straight forward
        }
        TableViewColumn {
            // ...
            // ... adding column to the end is straight forward
        }
    }
    

    An example would be helpful.



  • @m3g1dd
    Isn't this question for the QML sub-forum? You are looking for a QML solution.



  • @JonB Right, the post is moved to QML and Qt Quick sub-forum =)


Log in to reply