[PyQt] printing/saving a graphicsScene()
giulianc51
giulianc51 at gmail.com
Sun Mar 29 21:58:47 BST 2015
Hi all
I'm a new subscriber to this list :-)
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)
printer.setPageSize(QPrinter.Letter)
printer.setOrientation(QPrinter.Landscape)
printer.setOutputFormat(QPrinter.PdfFormat)
printer.setOutputFileName(outname)
painter = QPainter()
painter.setRenderHint(QPainter.Antialiasing)
painter.begin(printer)
scene.render(painter)
and like:
pixmap = QPixmap()
painter = QPainter(pixmap)
painter.setRenderHint(QPainter.Antialiasing)
scene.render(painter)
painter.end()
pixmap.save(outname,"JPG")
without success :-(
in the last test I also tried:
pixmap = QImage()
with the same result: none;
I also tried:
gv.render(painter) (gv=QGraphicsView);
this way we have not the list of warnings as with scene.render(), but
I obtain essentially
.... Painter not active ....
and I cannot print/save my scene;
I think I'm ignoring some subtle detail that does fail my tests: can
you help me?
thank you in advance, sorry for my bad english, best regards,
giuliano
More information about the PyQt
mailing list