how to get the index of a selected item into a TreeView



I'm trying to get the index of a selected item from a TreeView.
The code compiles, but I'm always getting 0.

This is what I'm doing:


typedef Glib::RefPtr<Gtk::TreeSelection> selection_t;

Gtk::TreeView * ItemSelector;
Glib::RefPtr<Gtk::ListStore> SelStore_;


selection_t Selection_=ItemSelector->get_selection();
int i=Selection_->get_selected()-SelStore_->children().begin();

cerr << i << endl;    // prints 0.

Why? Is there another way of getting the index? Other than storing an
integer along with every item in the treeview, showing the position of
each item.






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