Unsolved TreeModel, remove an item pointed by an index
-
Hi all.
I use the stuff described here that basically is a subclass of
QAbstractItemModel
My question is very simple but I feel I tried everything.
How can I erase an item of a TreeModel if I have an index pointing to it?
QModelIndex cycleModelIndex; QModelIndex cycleModelIndexChild; cycleModelIndex = model->index(2,0);
and I want to kill the item pointed by cycleModelIndex...
-
Hi,
Isn't that what
TreeNode * TreeModel ::nodeForIndex(const QModelIndex &index) const; void TreeModel ::removeNode(TreeNode *node);
are for ?
-
@SGaist Not really. They are only if your tree has only 1 column (i.e. that method removes the entire row). since the linked model only supports 1 role, however, you can just set the Qt::DisplayRole data of the index to QVariant() (you'll probably have to reimplement
setData
in the model to achieve this) -
This post is deleted!