0
我添加一個孩子到GtkVBox時有問題。 VBox在一個位於ScrolledWindows內部的GtkViewPort中。添加一個孩子到GtkVBox
它使用gtk_box_pack_end添加了孩子後,我檢查,如果它真的加入檢查爲Glist,看來,它的加入。儘管視覺上出現了任何東西,滾動的窗口變得非常大。就像增加了一些真正大而隱形的東西一樣。
的代碼如下:
GtkWidget *child;
switch (response_id) {
case GTK_RESPONSE_ADD:
//The see the code for this function read the other
//piece of code i'm posting
child = (GtkWidget *)newChild();
gtk_box_pack_end((GtkBox *)protocolsBox, child, 0, 1, 0);
GList *temp = gtk_container_get_children((GtkContainer *) protocolsBox);
//Here I do a while to check if the list has gotten bigger
break;
}
函數newChild對象()如下:
GtkHBox* newChild() {
printf("Creating new hbox\n");
countProt++;
//creation of all the widgets to look for a service
GtkHBox* new = (GtkHBox *) gtk_hbox_new(0, 0);
GtkEntry* nameEntry = (GtkEntry *) gtk_entry_new();
GtkEntry* domainEntry = (GtkEntry *) gtk_entry_new();
GtkHButtonBox *buttons = (GtkHButtonBox *) gtk_hbox_new(1, 0);
GtkRadioButton *tcpButton = (GtkRadioButton *) gtk_radio_button_new_with_label_from_widget(NULL, "tcp");
GtkRadioButton *udpButton = (GtkRadioButton *) gtk_radio_button_new_with_label_from_widget(tcpButton, "udp");
//packing the radio button widget
gtk_box_pack_start((GtkBox *) buttons, (GtkWidget *) tcpButton, 0, 0, 0);
gtk_box_pack_end((GtkBox *) buttons, (GtkWidget *) udpButton, 0, 0, 0);
//packing the outer most widget
gtk_box_pack_start((GtkBox *) new, (GtkWidget *) nameEntry, 1, 1, 0);
gtk_box_pack_end((GtkBox *) new, (GtkWidget *) buttons, 0, 0, 0);
gtk_box_pack_end((GtkBox *) new, (GtkWidget *) domainEntry, 1, 1, 0);
return new;
}
任何建議?
是的,代碼是它打包後的權利(沒有顯示在代碼示例中)。我嘗試了所有的演出功能:show_all show_now和show。這樣做會增加滾動的窗口很多,但沒有顯示。 – gvalero87 2010-09-22 20:16:51
你試過'show_all'你的主窗口上,只是爲了檢查你沒有忘了什麼東西?如果這不是問題,我認爲它一定是你程序中的其他地方。你能舉一個最小的例子來重現問題嗎? – ptomato 2010-09-23 21:42:04
我忘了說這個問題已經解決了。這是我的錯誤。我在另一個小部件上調用gtk_widget_show:s .. – gvalero87 2010-09-29 13:15:06