Re: [gtkmm] TreeView/TreeModel navigation



On Saturday 30 November 2002 2:40 am, Daniel Elstner wrote:

[snip]

> You can't do that in the STL unless you have random access iterators,
> which is not the rule.
>
>     Gtk::TreePath path (iter);
>     int idx = *path.get_indices().begin();
>
> should give you the row index.  A path is just a vector of indices, for
> instance: "1:4:2".  For a ListStore, the path always contains just one
> index.
>
> > > int row_num = iter - m_list_store_ref->children ().begin ()
> > >
> > > 2) How can I select the previous row?
> > >
> > > Gtk::TreeIter is a one-directional forward iterator.
> > > Any hints?
>
> Convert to a Gtk::TreePath and use path.prev().

[snip]

OK, thanks.  Now I understand that Gtk::TreePath is just a multi-dimensional 
(or for a Gtk::ListStore object, uni-dimensional) index to the particular row 
node, and that it can be converted to an iterator to that node, all is 
clearer.

Chris.




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