我正在使用gtk treeview在c中创建一个简单的表。
我正在这样做:
tree_view = gtk_tree_view_new();
store = gtk_list_store_new(4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
gtk_tree_view_set_model(GTK_TREE_VIEW(tree_view), GTK_TREE_MODEL(store));
renderer = gtk_cell_renderer_text_new();
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(tree_view), -1, "Register", renderer, "text", 0, NULL);
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(tree_view), -1, "Value", renderer, "text", 1, NULL);
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(tree_view), -1, "Type", renderer, "text", 2, NULL);
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(tree_view), -1, "Description", renderer, "text", 3, NULL);
GtkTreeIter iter;
gtk_list_store_append(store, &iter);
gtk_list_store_set
etc.
我如何控制每列的宽度?
答案 0 :(得分:0)
尝试这样的事情(可能不需要所有这些)。
gtk_tree_view_column_set_fixed_width (col, w); // just a hint
gtk_tree_view_column_set_min_width (col, w);
gtk_tree_view_column_set_max_width (col, w)
gtk_tree_view_column_set_sizing (col, GTK_TREE_VIEW_COLUMN_FIXED)
RTM了解具体细节。
答案 1 :(得分:0)
不要忘记使用gtk_tree_view_column_set_resizable()