Re: [gtkmm] Treeview help needed



bart wrote:

This always works for me, but if i'm not mistaken Christer mentioned
another way of accomplishing this. So i'd like to hear more ;-)


Basically, this is the code I'm using (now, I use libglademm, so my TreeView has already been created by libglade):

--------------------------------------------------

struct MyColumnrec : public Gtk::TreeModel::ColumnRecord {
    Gtk::TreeModelColumn<Glib::ustring> col1;
    MyColumnrec() { add(col1); }
} myColumnrec;

Glib::RefPtr<Gtk::ListStore> myModel =
    Gtk::ListStore::create(myColumnrec);

myTreeview->set_model(myModel);

Gtk::TreeViewColumn* col1 = Gtk::manage(
    new Gtk::TreeViewColumn("Col1"), myColumnrec.col1);
col1->set_sort_column_id(myColumnrec.col1);
myTreeview->append_column(*col1);

--------------------------------------------------

That's it. Just set_sort_column_id() and it should work. At least it works super for me for a bunch of TreeViews...

--
Christer




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