PDA

View Full Version : QGraphicsView: Save as PNG without displaying View?



SixDegrees
8th October 2010, 22:56
I've got an application using a QGraphicsView to display a collection of QGraphicsItems. I've also got a function that saves the currently displayed contents of the view as a PNG file.

I'd like to modify this application to run in batch mode: it would ingest a series of files controlling the contents of the view, zoom the view to ensure that all objects were visible, then save the contents as a PNG, just as it does now.

However, I'd prefer not to bring up the GUI itself while doing any of this, if possible. An additional wish would be the ability to specify the size of the final output PNG to ensure that all are uniform.

Will this work? I've had issues in the past with widgets not providing correct sizes, or having rendering go wonky, if they are not visible first. Things may be especially dicey if, for example, I decide to set the output size by first enlarging the application to full screen size.

Anyway, if there's a more sane, straightforward way of accomplishing this, I'd love to hear it.