qtqtreeview

How to add column before treecolumn in Qt qtreeview


I want to add a column before the tree column.
A similar thing is visible in the picture.
But I can't find any examples of that.

enter image description here


Solution

  • To achieve this. It is necessary to swap columns, as shown in the example. It works the same way on all Qt languages that have QTreeView.

    QTreeView *view;
    view->setModel(model);
    view->header()->swapSections(0, 1);