A sorted, filtered ListStore



Hi,

If I want to have a filtered (where one column in the model determines
if the row should be showed or not) list model, and I also want the
TreeView that's displaying the ListModel to be able to sort by
clicking on the column headers, I'd want to do something like:

 Glib::RefPtr<Gtk::ListStore> list_store = Gtk::ListStore::create(types);
 Glib::RefPtr<Gtk::TreeModelFilter> filter =
Gtk::TreeModelFilter::create(list_store);
 filter->set_visible_column(visible);  // visible is a TreeModelColumn
 Glib::RefPtr<Gtk::TreeModelSort> sort = Gtk::TreeModelSort::create(filter);
 Gtk::TreeView tree_view(sort);

So, I created a ListStore, then 'wrapped' (is there a .better term?)
it in a TreeModelFilter, then wrapped that in a TreeModelSort, and the
TreeView uses the TreeModelSort.

Joe



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