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

David Heremans dhran at scarlet.be
Thu Mar 21 20:09:56 CET 2013


On 03/11/13 08:30, Samuel Rødal wrote:
> 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?

Sorry for the late reply ( it took sometime before I could try this one out)
Indeed this clipping works nicely.

I already started implementing my proposal with the temporary QImage,
which also worked.
but even for my simple testcases the resulting PDFs were 20 times bigger
then the ones generated with the clipping you suggested.

Thanks for the hint!

David

-- 
openMSX - the open source MSX emulator that aims for perfection
http://openmsx.sf.net/


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 553 bytes
Desc: OpenPGP digital signature
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130321/2d46c898/attachment.sig>


More information about the Interest mailing list