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



On Tue, 2006-02-07 at 23:06 -0500, Amadeus W. M. wrote:
> On Tue, 07 Feb 2006 23:01:27 -0500, Amadeus W. M. wrote:
> 
> > 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.

distance (iteratorA, iteratorB) is the std c++ idiom for computing the
gap between iterators.






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