nileshsince1980
6th May 2010, 06:42
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
QGraphicsScene scene;
scene->addItem(rectItem);
scene->addItem(rectItem);
//.....
QImage img(1024,768,QImage::Format_ARGB32_Premultiplied);
QPainter p(&img);
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
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
QGraphicsScene scene;
scene->addItem(rectItem);
scene->addItem(rectItem);
//.....
QImage img(1024,768,QImage::Format_ARGB32_Premultiplied);
QPainter p(&img);
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