[SOLVED] Limit QPainter to a defined area
-
Hey there
Is there any possibility to define an area, let's say a rectangle in which the QPainter is visible only? So if I'm painting e.g. a line that starts outside this area and passes it, I will only see the part of the line which is inside that area.
Thanks for any help.
-
Are you using it with QGraphicsItem related classes?
If so, you re implement boundingRect(). Everything that you draw will only be visible inside of that rect. -
I think what your after is setting the clip region. Try QPainter::setClipRect. I haven't actually tried it, but I've used the same concept in other drawing systems, and I think it's what you're asking for.
-
Exactly what I was looking for, thx!