Request: Component::children()

Can we get something like: Array<Component*> Component::children()

so then we can do for example:

for (auto* c : foo->children())
    c->setVisible(false);
3 Likes

I’ve been meaning to do something like that for quite a while…

2 Likes

Just an idea, what about adding a addChildComponentOwned(Component* child, int zOrder = -1) function?

There are so many containers available which have an “owned” option, why not a component itself can own a child component. This would be interesting for patch-bay like components, which already use self organising children.

I think it’d be confusing to add that to the base class. You can easily do that yourself with a couple of lines of code, e.g. use Component::setProperty to flag the ones you want to be deleted, and then in your parent class’s destructor, delete them. Or just stick them in an OwnedArray.