[SOLVED] Limit QPainter to a defined area
General and Desktop
4
Posts
3
Posters
2.8k
Views
1
Watching
-
wrote on 2 Nov 2012, 15:36 last edited by
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.
-
wrote on 2 Nov 2012, 15:40 last edited by
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. -
wrote on 2 Nov 2012, 23:01 last edited by
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.
-
wrote on 5 Nov 2012, 18:22 last edited by
Exactly what I was looking for, thx!
1/4