如何更改树视图的高度和宽度?

时间:2013-09-21 01:20:57

标签: c treeview gtk height width

我一直坚持这个问题。我有一个显示表格的树视图。表的大小取决于用户的输入。我想让它看起来不错,当表只有2列时,有很多空间无法使用。那么如何更改树视图的高度和宽度?感谢

static void show_results(struct listaObjetos *vectorObjetos[],int cantidad, int tamanoMochila){
int i; 
char msg[180] = {0}; 
/
GtkCellRenderer *renderer; 
GtkTreeViewColumn *column;  


treeView = gtk_tree_view_new ();
 gtk_widget_set_size_request (GTK_WIDGET (treeView), 0, 0);


window2 = gtk_window_new (GTK_WINDOW_TOPLEVEL);


gtk_window_set_title(GTK_WINDOW(window2), "Resultados"); 

gtk_container_set_border_width(GTK_CONTAINER(window2),10);

gtk_widget_set_size_request (window2, 480, 320);

renderer = gtk_cell_renderer_text_new(); 

column = gtk_tree_view_column_new_with_attributes("column1        ", renderer, "text",COLUM1, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeView), column);

column = gtk_tree_view_column_new_with_attributes("colum2       ", renderer, "text",COLUM2, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeView), column);

column = gtk_tree_view_column_new_with_attributes("colum3      ", renderer, "text",COLUMN3, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeView), column);

column = gtk_tree_view_column_new_with_attributes("colum4", renderer, "text",COLUM4, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeView), column);

store = gtk_list_store_new (4, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT,G_TYPE_INT);

for(i=0; i<cantidad; i++)
{
    gtk_list_store_append (store, &iter);
    gtk_list_store_set (store, &iter, COLUM1, vectorObjetos[i]->x,COLUMN2, 
                            vectorObjetos[i]->y, COLUM3, vectorObjetos[i]->q,
                                    COLUM4,vectorObjetos[i]->z,-1);
}
gtk_tree_view_columns_autosize(GTK_TREE_VIEW (treeView));
gtk_tree_view_set_model (GTK_TREE_VIEW (treeView), GTK_TREE_MODEL (store));
g_object_unref (store);


scrolledWin = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledWin),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

table = gtk_table_new(10,10,FALSE); 

gtk_table_set_row_spacings (GTK_TABLE (table), 5);
gtk_table_set_col_spacings (GTK_TABLE (table), 5);
gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);

gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolledWin), table);
label = gtk_label_new("Objetos sujetos a analisis");

gtk_table_attach_defaults(GTK_TABLE(table), label,4,5,0,1); 

g_snprintf(msg, sizeof msg, "A message here ",
                                cantidad, tamanoMochila );
label = gtk_label_new(msg);
gtk_table_attach_defaults(GTK_TABLE(table), label,0,10,1,2); 
label = gtk_label_new(" ");

gtk_table_attach_defaults(GTK_TABLE(table), label,3,4,2,4); 

gtk_table_attach_defaults (GTK_TABLE(table), treeView, 4,5,2,4); 
label = gtk_label_new(" ");

gtk_table_attach_defaults(GTK_TABLE(table), label,5,6,2,4); 

gtk_container_add (GTK_CONTAINER (window2), scrolledWin);
gtk_widget_show_all (window2);

}

我尝试发布带有结果的图片,但我不能因为声誉

0 个答案:

没有答案