Limit paint area
I have a widget for which I would like to hand certain areas of the widget's "paint area" of to other classes for drawing. However I would like these other classes to only be able to paint in their provided areas, i.e they have their own local coordinate system. Any ideas on the best way to accomplish something like this?
The best was if these other classes was also widgets
and the master widget simply was a container for these widgets.
Then each would paint inside its area and not possible to paint outside.
However, you can send the painter & to some function in X class and let it draw.
You can use clipping to keep them restricted.
But its sounds messy unless those other classes are utility classes and do not have any normal painting beside the drawing they do to the master widget.
I guess I should of given a bit more information here.
What I actually have is class hierarchy that has a base of QGraphicObject. The idea here is that sections can be added by creating a section class which as you correctly said does not have it's own paint function, but instead receives the masters painter. The master painter however before providing the painter should of set up a new local coordinate system that sets 0,0 top left for example of this sub area.
- just in case the link doesn't work https://postimg.org/image/yxbjdq0c3/
I think I understand clipping, but i believe i would some how need to limit the window before providing it to the help class.
Maybe you can use
to translate the sub area so sum area start at 0,0 .
and combined with clipping it could protect the full area somewhat.
Thanks for the advice mrjj. I used the translate functions and the save and restore to ensure that each section has a logical coordinate system that makes sense to it.