Children iteration

rodrigofarias77

10-08-2007 18:14:50

What is the sequence of code to iterate through all children of a widget?

Regards
Rodrigo

kungfoomasta

10-08-2007 19:45:21

std::vector<Widget*>::iterator it;
for( it = mChildWidgets.begin(); it != mChildWidgets.end(); ++it )
{
Widget* w = (*it);
}

This is how I do it internally. What are you trying to achieve? That reminds me, I should expose acess to the child list. I can add a simple function like:

std::vector<Widget*>* Widget::getChildList();

Would this be beneficial to you?

rodrigofarias77

10-08-2007 20:06:05

Thank you KungFooMasta :)

Actually, the version 0.9.5 already has the method std::vector<Widget*>* getChildWidgetList(). It is a shame, but I do not know how to get the Widget from the vector<Widget*>*...

Regards
Rodrigo

kungfoomasta

10-08-2007 22:59:25

std::vector<Widget*>* ChildList = mWidget->getChildWidgetList();

std::vector<Widget*>::iterator it;
for( it = ChildList->begin(); it != ChildList->end(); ++it )
{
Widget* w = (*it);
if( w->getInstanceName() == "UniqueWidgetName" )
...
}

That's all you need to do. :wink:

rodrigofarias77

11-08-2007 00:40:11

Thank you again, kungfoomasta :)

Regards
Rodrigo