我遇到了GTK + C應用程序的問題。我有一個容器,它在啓動應用程序時包含一個按鈕。在運行期間,用戶交互必須使這個小部件包含更多這些小部件。
我需要編寫一個刪除所有「舊」內部按鈕的函數,然後添加列表中的所有內容並最終刷新視圖。這是我正在寫的,但一些部分丟失(TODO)刪除GTK +容器子項,重新填充它,然後刷新
void refresh_sequence_panel()
{
GSList* iterator = NULL;
GtkWidget* button;
// TODO: Here the container must be empty
// Now add all the buttons
for (iterator = steps; iterator; iterator = iterator->next) {
button = gtk_button_new_from_stock(GTK_STOCK_ADD);
gtk_widget_set_size_request(button, SEQ_BUTTON_W, SEQ_BUTTON_H);
gtk_box_pack_start(GTK_BOX(sequence_panel), button, FALSE, FALSE, 5);
handler_id = g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(seq_popup), GTK_BOX(sequence_panel));
}
// TODO: Now refresh the view, so I can see the changes...
}
希望有人能幫忙,謝謝!
謝謝你,我肯定需要刷新。 – TheUnexpected 2012-02-09 11:10:21
您也可以這樣做: gtk_container_foreach(GTK_CONTAINER(container),(GtkCallback)gtk_widget_destroy,NULL) – 2017-06-30 07:44:49