What is best approach to not draw items outside the QGraphicsView?
hellozee last edited by hellozee
I wanted to not draw the part of the QGraphicsItem which is outside the screen rectangle.
I wanted something like this:
But currently I am getting this:
In short, according the above couple of photos, I wanted the red rectangle to not to be drawn outside the screen rectangle which is determined by the White Rectangle at the time of initialization.
Asperamanca last edited by
You can make all your items children of a single custom QGraphicsItem or QGraphicsWidget, which is the only item directly inserted in the scene. If you set the flag ItemClipsChildrenToShape, no item will draw beyond the boundingRect of that parent item. Then, you need to keep the size of the item up-to-date if your visible area changes.
hellozee last edited by
@Asperamanca Thanks, it is working the way I wanted.