Search code examples
c++linuxsignalsgtkmm

GtkTreeView Column Header Click Event


I have a question. I have a GtkListStore and a GtkTreeView, and I want to sort the GtkListStore and update the result to the GtkTreeView when the user clicks on a certain column of the GtkTreeView. I am assuming that the columns are clickable, and cannot be re-ordered, so the numerical order of the columns can be used to set the sorting column's index. But I cannot seem to find which signal gets emitted when the user clicks on the header of a particular column. I have gone through the GTKMM documentation time and again, but it does not seem to be mentioned!


Solution

  • Use Gtk::TreeView::get_column(<column-no>) to get a particular column and attach to its "clicked" signal using Gtk::TreeViewColumn::signal_clicked():

    Gtk::TreeViewColumn* col = myview.get_column(SOME_COLUMN_NUMBER);
    col->signal_clicked().connect(sigc::mem_fun(*this,&some_method));