Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to get the index of a TreeItem in a TreeModel
Infinity last edited by
I have a treeModel based on this example:
I would like to delete a specific item in the tree model, but this item is not selected. How can I get the index of a treeItem?
So how to do you know what item you want to delete?
See https://doc.qt.io/qt-5/model-view-programming.html#model-classes on how to get an index to an item
gde23 last edited by
If you just want to delete a certain row/column than you can use
QAbstractItemModel::index(int row, int column)
However be sure to call beginRemoveRows() and endRemoveRows() when you're deleting it.
@gde23 It's a tree - the parent is important. Therefore my question...