PDA

View Full Version : browse through all the child object of a widget



qlands
5th July 2011, 21:00
Hi,

Is there any way to browse through all the children objects of a widget. Maybe this should be recursively...

Any idea how to do this?

Thanks,
Carlos.

d_stranz
5th July 2011, 21:20
void BrowseChildren( QWidget * parent )
{
QObjectList children = parent->children();
QObjectList::const_iterator it = children.begin();
QObjectList::const_iterator eIt = children.end();
while ( it != eIt )
{
QWidget * pChild = (QWidget *)(*it++);
BrowseChildren( pChild );
}
}

Of course, you might want to do something with each child widget as it is discovered. Read the docs: the order of the list is determined by the stacking order of the widgets. Bringing a widget to the top of the stack by raising it changes the order.

qlands
6th July 2011, 08:23
Excellent. Thanks.