Re: Gtk::TreeSelection::get_selected_rows()
- From: Bob Caryl <bob fis-cal com>
 
- To: Doug McLain <dougmclain cayf org>
 
- Cc: gtkmm <gtkmm-list gnome org>
 
- Subject: Re: Gtk::TreeSelection::get_selected_rows()
 
- Date: Wed, 19 Oct 2005 10:08:01 -0500
 
Doug McLain wrote:
The gtkmm tutorial Treeview sections gives an example of getting 
multiple selections using the selected_foreach_iter() slot, but I want 
to try get_selected_rows().  I don't know how to use the return value 
though, ListHandle_Path.  Could someone explain or show me a simple 
example?
Thanks
Doug
http://gtkmm.org/docs/gtkmm-2.4/docs/reference/html/classGtk_1_1TreeSelection.html#a7 
Gtk::TreeSelection::get_selected_rows() returns a ListHandle_Path which 
has an operator that lets you convert it to a 
std::vector<Gtk::TreeModel::Path>.
Ok... here's what you should do:
// code snippet starts
// all this presupposes you've set up your tree view, a list or tree 
store, and a tree view selection somewhere previously
std::vector<Gtk::TreeModel::Path> pathlist;
pathlist = myTreeViewSelection->get_selected_rows();
// Now, you have a list of paths to the selected rows.  For each entry 
in the list, you can get an iterator which can be deferenced to a 
Gtk::TreeView::Row.
for(gint i = 0; i < pathlist.size(); i++)
{
   Gtk::TreeModel::iterator iter = 
myTreeView->get_model().get_iter(pathlist[i]);
   Gtk::TreeModel::Row row = *iter;
   // now do what you need to do with the data in your TreeModel
}
//code snippet ends
As always, if I'm all wet, you guys correct me.
Hope this helps.
Bob
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]