How to Insert/Update/Remove in a C++ TreeModel and a QML View
-
Hello,
I need for my
QMLUI to use aTreeView.
I based my TreeViewModel from this exampleI use
custom Dataand they are displayed correctly. However, I have trouble to understand how I couldupdatethe view when I need for example toinsertanew Data.When using for example a
QAbstractListModel, I will use functions likebeginInsertRows()etc.
It is easy to find theindexbecause you have aQListofData.
However, in aTreeModel, the only Data you have is the root of theTreeItem.So I don't know what
indexto give tobeginInsertRows()if I want to insert (or update or remove) aNode.
Could someone explain it to me ?I don't know if my explanation was clear, my english is not perfect. If you have trouble to understand my question, just tell me and I will try to make it more clear.
Thanks a lot and have a good day !
-
- Check Editable Tree Model Example.
- Item delegate has
styleData.indexspecial property that holds QModelIndex.