Title: Gtk75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0TreeModel75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0iterator usage when implementing TreeModel
Tags: c++;model-view-controller;gtk;gtkmm;gtktreeview
Question: I am trying to implement own TreeModel for use in TreeView.
I have subclassed Gtk75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0TreeModel and currently trying to override virtual methods with my own implementation.
But i have a problem with very basics of it. Say, we have
virtual bool iter_next_vfunc(const iterator &amp;iter, iterator &amp;iter_next) const;
function where i am supposed to read iter variable, somehow understand where it points to and based on this, fill iter_next with point next to the current.
But i do not understand how to do this.
What is 'index', 'pointer' or whatever based on what i could understand where iter is pointing to?
Comment: Could be the quick'n'dirty way, yes, thank you. But in general it is not very cool; not the best way to solve things.

Comment: Well, it could be the way if there is no high-level options, using only gtkmm tools and not involdving direct gobj* poking, but otherwise it is no go.

Comment: You were right, Ancurio. Apparently there is no higher level abstraction for this as far as i researched. Despite how unfortunate this is, it is the answer. Please, create one so i can accept it.

Comment: Hmm, how about you just get the plain C GtkTreeIter from the "gobj()" function, and then treat it as that? In C, GtkTreeIter has one "stamp" member (which is to identify which TreeModel it belongs to) and three general purpose gpointers to be used by the implementor (ie. you). See [C docs](http://developer.gnome.org/gtk/2.24/GtkTreeModel.html#GtkTreeIter-struct)

Comment: So you're saying you're positive this is definitely not the way to go?

Comment: Hmm, if it was a real GObject you were manipulating here, I would agree. But it's just a plain C struct, so..

Comment: Well, what were you expecting, accessor functions for every struct member? =P

Here is the accepted answer: Directly access the underlying GtkTreeIter struct through gobj(), and fill it with the relevant data ('stamp' should be the same across all iters of the same model). (Reference)


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 7, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2012:00:10/17/12', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<c++><model-view-controller><gtk><gtkmm><gtktreeview>', 'Title': 'Gtk::TreeModel::iterator usage when implementing TreeModel', 'ViewCount': 423, 'id': 12926440, 'user_AboutMe': None, 'user_AccountId': 1942336.0, 'user_DisplayName': 'Alexander Tumin', 'user_Reputation': 1531.0, 'user_Views': 115.0, 'user_id': 1748237.0}}