[PyQt] Partially Solved Re: printing/saving a graphicsScene()
giulianc51
giulianc51 at gmail.com
Wed Apr 1 11:55:07 BST 2015
Il giorno Sun, 29 Mar 2015 22:58:47 +0200
giulianc51 <giulianc51 at gmail.com> ha scritto:
Hi all
>
> ......
> I'm on qt 4.4.8, pyqt 4.9.3 and debian wheezy; my problem is printing
> a QGraphicScene() on a PDF file or saving it to an image;
>
> I followed some examples on the net like:
> printer = QPrinter(QPrinter.HighResolution)
> ......
> and like:
> pixmap = QPixmap()
> painter = QPainter(pixmap)
> painter.setRenderHint(QPainter.Antialiasing)
> scene.render(painter)
> .......
> without success :-(
I have had some success with these instructions:
outputImg = QPixmap(xVp,yVp)
painter = QPainter(outputImg)
targetrect = QRectF(0,0,xVp,yVp)
sourcerect = QRectF(-20,-20,xVp+50,yVp+50)
scene.render(painter,targetrect, sourcerect)
.....
it seems to be determinant the definition of targetrect & sourcerect; I
don't have complete control on the saving procedure but this is
a good improvement (for me) :-)
tia, sfmbe, best regards,
giuliano
More information about the PyQt
mailing list