El 2 / desembre / 2009 03:45, Milosz Derezynski <[email protected]> ha escrit: > 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 <[email protected]> >> >> On Tue, 2009-12-01 at 21:55 +0100, Glus Xof wrote: >> > 2009/12/1 Murray Cumming <[email protected]>: >> > > 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é >>
Honestly, I have seen the Gtk::TreeModel::Path::get_indices() method before, but I didn't consider it because I didn't know why the array of int(s), while I need just one int... Jose came again to give me light... because TreeStore nodes also exist... So, Glib::RefPtr <Gtk::ListStore> m_refTreeModel; Gtk::TreeModel::iterator iter; Gtk::TreeModel::Path cellpath=m_refTreeModel->get_path(iter); std::vector<gint> rowindex = cellpath.get_indices(); The right value is rowindex[0]... ;) Thanks to all, Glus. _______________________________________________ gtkmm-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/gtkmm-list
