Re: Cast Gtk::TreeModel::iterator to int



A Gtk::TreeModel::Path is just a wrapper for a GtkTreePath which truly is just an array of ints. If you have a simple vector-like model then you can get a row number from the TreePath like Jose said it.

2009/12/2 José Alburquerque <jaalburquerque cox net>
On Tue, 2009-12-01 at 21:55 +0100, Glus Xof wrote:
> 2009/12/1 Murray Cumming <murrayc murrayc com>:
> > On Mon, 2009-11-30 at 19:25 +0100, Glus Xof wrote:
> >> Hello guys,
> >>
> >> A very stupid question... (but I don't find the answer).
> >>
> >> Is it possible to cast a Gtk::TreeModel::iterator value to int (or gint) ???
> >
> > If that int should be a row number, then you can convert the iter to a
> > Gtk::TreeModel::Path.
> >
>
> Sorry Mr. Cumming, I don't reach to see for the moment what you
> suggest... I'd need the row number as an int (or gint) value, not as a
> Gtk::TreeModel::Path...

To get a row number from a path, use
Gtk::TreeModel::Path::get_indices().  It returns an array of the
components in the path, which can be stored in a standard container.

If the model is a ListStore, the first component of the path should be
the row number.  If it is a TreeStore, the first component is also a row
in the model, but the next component represents the location of a child
row with respect to the parent, and so on.

--
José







_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list



--
Please note that according to the German law on data retention,
information on every electronic information exchange with me is
retained for a period of six months.
[Bitte beachten Sie, dass dem Gesetz zur Vorratsdatenspeicherung zufolge
jeder elektronische Kontakt mit mir sechs Monate lang gespeichert wird.]


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