PDA

View Full Version : Adding SubColumn to the root item in the QTreeView



Mohsin
24th May 2021, 06:13
I have implemented a QTreeView using the SimpleTreeModel (https://doc.qt.io/qt-5/qtwidgets-itemviews-simpletreemodel-example.html) example.

But now I want to add two sub-columns in one root item. For example, Entries "item A" and "Value" will be inside one root entry "Data A". Similarly Entries "item B" and "Value" will be another root entry "Data B".

Can anybody tell how it can be done?

Thanks in advance :)

ChrisW67
25th May 2021, 08:37
You either change your custom model to present the tree structure that way, or you overlay a QAbstractProxyModel sub-class to do this rearrangement in the fly. Which you choose will depend on where else the model might be used and what your are trying to achieve.