问题
I want to make a sorted list in a TreeView. I know that user can sort the contents by clicking the column header. But how to do it programmatically (such as in every change of its content)?
回答1:
Wrap the model with a GtkTreeModelSort.
回答2:
example:
void gtktreeview_sort_force(GtkTreeSortable *sortable)
{
gint sort_column_id;
GtkSortType order;
gtk_tree_sortable_get_sort_column_id(sortable, &sort_column_id, &order);
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(sortable), GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, order);
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(sortable), sort_column_id, order);
}
来源:https://stackoverflow.com/questions/9194588/how-to-programmatically-sort-treeview