How to clip child component?


I’m a bit confused with simple problem (or too tired for today :))
I have a component which in its paint() method draws some rounded border and also contains child component which should be clipped to that border.

Well, how to clip that child component to specific shape?

I know how to use clipping regions with paths within the same paint() but how it could be done for nested components.
I found a workaround creating simple ImageEffectFilter which do the clip and using setComponentEffect() for that child comp, but I feel there is some simpler solution.

Thanks in advance for suggestions…


Make a Component that sits on top which has a transparent hole in the middle, in the shape of a rounded rectangle:


You can do this in a single call to Graphics::fillPath(), use the winding properties of the path to first place a rectangle and then a rounded rect into the path.

Thanks, it works. I knew it should be simple :slight_smile: