TreeModel, remove an item pointed by an index
Patou355 last edited by Patou355
I use the stuff described here that basically is a subclass of
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...
Isn't that what
TreeNode * TreeModel ::nodeForIndex(const QModelIndex &index) const; void TreeModel ::removeNode(TreeNode *node);
are for ?
VRonin last edited by
@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
setDatain the model to achieve this)
Patou355 last edited by
This post is deleted!