How to Programmatically Sort TreeView

元气小坏坏 提交于 2019-12-12 02:53:30

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!