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



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.


Oh, yea, and 

SelStore->children().end() - SelStore_->children().begin() = -1,
even though
SelStore->children().size() = 199   (correct in my case).






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