Re: [gtkmm] Updating a custom TreeModel



Murray Cumming wrote:
On Sun, 2004-03-28 at 03:25, Tor Arvid Lund wrote:

It looks like the path can be created from the iterator, but I cannot see how I should generate the iterator. Could anyone give me an example or perhaps point me to one?


Maybe I'm not seeing the specific problem here, but isn't it you that's
meant to decide how to create an iterator, because its your custom
model?


It's probably that I don't understand fully what it is I'm doing :-)

Maybe I just don't get how an iterator works... Let's say that:
I have a vector myVec<myClass>, with elements a and b. These are shown in the TreeView. Then I add element c to this vector. As far as i can tell, I have to create an iterator that points to c.

But I can't just say Gtk::TreeModel::iterator iter = c; can I?

Well, I may have found a workaround for the time being (since it really is a ListView), but it doesn't seem very elegant:

Gtk::TreeNodeChildren allNodes = myCustomTreeModel->children();
Gtk::TreeNodeChildren::size_type numberOfNodes = allNodes.size();
Gtk::TreeModel::Path path;
path.push_back(num);
Gtk::TreeModel::iterator iter = myCustomTreeModel->get_iter(path);
myCustomTreeModel->row_inserted(path, iter);

<end of code>

But if someone could enlighten me as to how the TreeIters work, I would be grateful, and I could make this work if I later need a TreeView where the nodes do have children.

--
Tor Arvid Lund               ,''`.
http://totto.homelinux.net  : :' :
GnuPG key ID: 0xF335ED1E    `. `'
find it at pgp.mit.edu        `-

Attachment: signature.asc
Description: OpenPGP digital signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]