[Interest] QGraphicsScene.render() does not respect source rect ?

Samuel Rødal samuel.rodal at digia.com
Mon Mar 11 08:30:22 CET 2013


On 03/05/2013 08:58 PM, David Heremans wrote:
>
> Hello,
>
> I seem to have a small problem here with the render function of the
> QGraphicsScene.
> I'm trying to print parts of a scene onto several pages, however it
> seems that
> the render method does the scaling as requested , but does not clip the
> origin
> to the source QRectF.
> The scene contains several items that are all arranged in a tree like
> structure, something like this:
>
>      |
> +++++++++  <= bar that is parent of all items
> | | | | |
> O O O O O  <= a set of items below it.
>
>
> and if I restrain the source QRectF to one or more items it will still print
> the parent and the other children outside of the given rectangle. Filling up
> the rest of the page which I definitely don't want.
>
> I attached a small minimal example to demonstrate what I mean.
> If I do not have the parent-item each ellipse ends up on a separate page
> in the
> first PDF generated. As soon as a attach them to a parent you will see
> in the
> second pdf that it will draw all the items to the right also...
>
> Is there a way to avoid this? Or am I obliged to first render onto a
> temporary image that I then copy towards the printer(or pdf)?
>
> rgds,
>
> David H
>
> PS: I'm using Qt 4.8.1 on linux and 4.7.4 on windows 7 here, both of
> course giving the same result :-)

Maybe you could set a clip using QPainter before calling render?

--
Samuel




More information about the Interest mailing list