我怎样才能最大化GtkGrid来填充整个GtkWindow?

时间:2013-03-21 15:37:11

标签: gtk gtk3

我使用简单的布局制作了基本的GtkGrid应用程序,但我无法使GtkGrid填充整个GtkWindow。这是用于创建布局的代码:

GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size(GTK_WINDOW(window), 800, 600);


GtkWidget *grid = gtk_grid_new();
g_signal_connect(window,"destroy", G_CALLBACK(gtk_main_quit), NULL);

GtkWidget *vpaned = gtk_paned_new(GTK_ORIENTATION_HORIZONTAL);

gtk_paned_set_position (GTK_PANED (vpaned), 400);

GtkWidget *label = gtk_label_new("Label1111111111111111111111111111111");
GtkWidget *label2 = gtk_label_new("Label2");
GtkWidget *label3 = gtk_label_new("Label3");
GtkWidget *label4 = gtk_label_new("Label4");
gtk_paned_pack1 (GTK_PANED (vpaned), label, FALSE, TRUE);
gtk_paned_pack2 (GTK_PANED (vpaned), label2, FALSE, TRUE);

gtk_widget_show (label);
gtk_widget_show (label2);
gtk_widget_show (label3);
gtk_widget_show (label4);
gtk_widget_show (vpaned);

gtk_grid_attach(GTK_GRID(grid), label3, 0,0,1,1);
gtk_grid_attach(GTK_GRID(grid), vpaned, 0,1,1,1);
gtk_grid_attach(GTK_GRID(grid), label4, 0,2,1,1);

gtk_widget_show(grid);

gtk_container_add(GTK_CONTAINER(window), grid);

gtk_widget_show (window);

1 个答案:

答案 0 :(得分:4)

您可以查看expand属性并确保其设置为TRUE(默认情况下,如果您在林间设计师中使用您的UI) - https://developer.gnome.org/gtk3/stable/GtkWidget.html