QgraphicsView/Scene to PNG image
Hi All,
My application consists of QGraphicsView/Scene nad I have added QGraphicsItems of different shapes line rectangle, circle etc. etc.
I want to convernt whatever is in QGraphicsScene to image file (e.g. scene.png).
Can you tell how to do this ???
I have tried following code
Code:
scene->addItem(rectItem);
scene->addItem(rectItem);
//.....
scene.render(&p);
p.end();
img.save("scene.png");
But above code only creates png file with background image (which I draw in
QGraphicsScene:drawBackground(QPainter * painter, QRectF const & /*clip*/) { } method using QPainterPath class.
The items which I added doesnt get added in png file.
Can you anybody tell me what I am missing ??
Thanks in advance.
Nilesh
Re: QgraphicsView/Scene to PNG image
At what cordinates are your items ? are they within the 1024x768 rect in the scene ?
Re: QgraphicsView/Scene to PNG image
I have set scene rect's as (0, 0, 550, 700).
I want entire scene should get saved as a image.
Re: QgraphicsView/Scene to PNG image
(0, 0, 550, 700). seems ok.
try changing image format from ARGB32premultiplied to some other and check if it works.