Thank you, the assumptions you made are right. Another newbie question:
Should I call delete() on each widget created with new() inside this
widget1, or will widget1 do it itself when it will die?
Sorry for such a lame understanding of c++ :-)
gtkmm provides the manage() and add() methods to create and destroy widgets. Every widget except a top-level window must be added or packed into a container in order to be displayed. The manage() function marks a packed widget so that when the widget is added to a container, the container becomes responsible for deleting the widget.
MyWidget::MyWidget()
{
Gtk::Button* pButton = manage(new Gtk::Button("Test"));
add(*pButton); //add aButton to MyWidget
}
Now, when MyWidget is destroyed, the button will also be deleted. It is no longer necessary to delete pButton to free the button's memory; its deletion has been delegated to MyWidget.