PDA

View Full Version : Rendering QGraphicsScene to QPixmap to save



Rooster
9th April 2009, 06:17
I am trying to save a QGraphicsScene to a QPixmap so that I can save the image. The reason that I am trying to do this is because I have created a gui to go with some research that I am doing and need to get some graphics for a paper I am writing.

here is how I am doing it right now. I know it is not working because I am getting a false returned from the QPixmap save function. Scene is my QGraphicsScene with an image on it.

void Control::save_graph()
{
QPixmap *tosave = new QPixmap(1000,400);
QPainter painter(tosave);
scene->render(&painter);
painter.end();
if(tosave->save("Users/user/image","PNG"))printf("save is good");
else printf("save no good");


}


Any help here would be greatly appreciated.

aamer4yu
9th April 2009, 06:24
Is the path you are saving to valid ? Just try toSave->save("image","PNG");

Also you can query sceneRect() and construct the pixmap based on this size :)