Hey Paul,

You are undoubtedly correct about my inefficiency; however, the reason my example uses the std::vector<Gtk::TreeModel::Path> is because its use is "chapter-and-verse" from the docs:

http://www.gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/ch03s05.html

I found this reference in the following post: http://mail.gnome.org/archives/gtkmm-list/2004-November/msg00221.html

Bob

Paul Davis wrote:

// 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;

slightly more efficient, perhaps, to do:

for (TreeSelection::ListHandle_Path::iterator i = pathlist.begin(); i != pathlist.end(); ++i) {
           Row row = *(model.get_iter (*i));
            ...
   }





_______________________________________________
gtkmm-list mailing list
gtkmm-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Reply via email to