Destroying Child Widgets

AshMcConnell

18-06-2010 15:47:20

Hi Folks,

I am trying to remove all widgets that are children of a ScrollView widget.
size_t count =_newsScroll->getChildCount();
for ( int i=0; i < count; ++i )
{
MyGUI::Gui::getInstance().destroyChildWidget(_newsScroll->getChildAt(i));
}


It complains that the Widget doesn't exist.

Any idea what I am doing wrong?

Thanks for your help
All the best,
Ash

Altren

18-06-2010 16:23:21

First of all destroyChildWidget destroys child widget of Gui, i.e. root widgets only.
You should use destroyWidgets
MyGUI::Gui::getInstance().destroyWidgets(_newsScroll->getEnumerator());
And for destroying any widget you should use MyGUI::Gui::getInstance().destroyWidget(...);
That destroyChildWidget should be obsolete actually.

AshMcConnell

18-06-2010 16:27:59

Thanks Altren,

That's much easier indeed!

Thanks for your help!
All the best,
Ash