How simpletreeview example works?
Dear All,
I am trying to learn how the example SimpleTreeView works.
I can hardly understand one, maybe the key part of the implementation.
void TreeModel::setupModelData(const QStringList &lines, TreeItem *parent)
{
QList<TreeItem*> parents;
...
// Append a new item to the current parent's list of children.
parents.last()->appendChild(new TreeItem(columnData, parents.last()));
...
}
Could you kindly explain me how it works?
parents is declared in TreeModel::setupModelData
and as far as I understand, it's scope is in this method.
So when exited from setupModelData the list is destroyed.
How then can the model access all the items?
I presume that all is hiden in QModelIndex mechanism.
But unfortunately I cannot understand it's profundity even though I have read the docs.
I would higly appreciate all your comments.
Thank you very much.
Re: How simpletreeview example works?
Sorry guys for taking your time.
I think that I got it now.
All "secrets" are in TreeItem class