how to destroy All ChildWidgets

planB

02-09-2010 03:36:26

hi, there!

in my app, i create some new wighets in a created parent wighet.
when i click somewhere, i want to clear the parent wighet's all child, and create other new wighets in this parent wighet.

how can i do to clear the parent wighet's all wighet.
i noticed that there is a method _destroyAllChildWidget(), but it is protected.

my.name

02-09-2010 09:02:23

while (parent->getChildCount() != 0)
MyGUI::WidgetManager::getInstance().destroyWidget(parent->getChildAt(0));

planB

04-09-2010 01:42:02

tks.
i suggest that in your new version, you may add public function, wighet::removeallchild();

removeallchild()
{
while (wighet->getChildCount() != 0)
MyGUI::WidgetManager::getInstance().destroyWidget(wighet->getChildAt(0));
}



that may be easy to use.

Altren

04-09-2010 08:14:30

Another way is
MyGUI::EnumeratorWidgetPtr childs = widget->getEnumerator();
MyGUI::WidgetManager::getInstance().destroyWidgets(childs);