VNarasimhaM
VNarasimhaM

Reputation: 1560

How to move all child widgets to another container

I have a gtk widget (from gtk_dialog_new()) which was created in a different function and bunch of widgets added to it. Now I want to reparent all the children of this widget to another container. Something like:

get_widget_get_all_childrent(list);
//loop over list and reparent all children

Upvotes: 0

Views: 393

Answers (1)

VNarasimhaM
VNarasimhaM

Reputation: 1560

Actually I found the answer after a bit of googling.

First I need to get a list of children:

GList* list = gtk_container_get_children();

      //then loop over and reparent

     g_object_ref(widget);
     gtk_container_remove(GTK_CONTAINER(old_parent), widget);
     gtk_container_add(GTK_CONTAINER(new_parent), widget);
     g_object_unref(widget);

Upvotes: 1

Related Questions