Results 1 to 2 of 2

Thread: How simpletreeview example works?

  1. #1

    Default 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.

  2. #2

    Default Re: How simpletreeview example works?

    Sorry guys for taking your time.

    I think that I got it now.

    All "secrets" are in TreeItem class

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.