Hi all,

I developed a GUI application using PyQt which comport a QGraphicsView. In this QGraphicsView I have a QGraphicsScene with a lot of items (more than 10'000): polygons, rectangles, texts, etc.

How can I save it as an image like it appears on the screen (.png for example)? I couldn't find any example of this. Should I use QImage or something like this?

Thank you

Patrick

Hi Woooee, thanks for you answer!

I saw that I could save a QImage, but my problem is: how to transfer all my items into a QImage from my qgraphicsview or qgraphicsscene.

Any idea?

Thanks

Patrick

I would try render first, but I have never tried it. From the docs at http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qgraphicsview.html

QGraphicsView.render (self, QPainter, QRectF target = QRectF(), QRect source = QRect(), Qt.AspectRatioMode mode = Qt.KeepAspectRatio)

Renders the source rect, which is in view coordinates, from the scene into target, which is in paint device coordinates, using painter. This function is useful for capturing the contents of the view onto a paint device, such as a QImage (e.g., to take a screenshot), or for printing to QPrinter.

You could also try the PyQt Forum

Edited 6 Years Ago by woooee: n/a

It works perfectly with the render method of QGraphicsScene.

Thank you very much Woooee, it helped me very much!

See you

Patrick

This question has already been answered. Start a new discussion instead.