QGraphicsView/Scene to png image
Hi All
My application consists of QGraphicsView/Scene with some shapes like rectange items.
I have option to save entire scene to an image file using following code
Code:
scene->addItem(rectItem);
scene->addItem(rectItem);
//.....
scene.render(&p);
p.end();
img.save("scene.png");
Image is gets saved propertly. but when I tried to zoom in GraphicsView by setting matrix. and then save the image, tthe image which I get is of initial scale level.
e..g Initial scale is 1 after zoom in say GraphicsView's scale becomes 2
but image (scene.png) is created with initial scale of 1.
Can any body tell what I missing ??
Thanks in advance.
Nilesh
Re: QGraphicsView/Scene to png image
You are saving an image with a fixed size always:
You have to calculate the correct image size for the zoomed scene.
[EDIT]:
Oh, I see now what you mean.
You want a fixed size image, and only the zoomed part of the scene in it.
You have to draw the visible scene rect in to the image then.
Re: QGraphicsView/Scene to png image
I want entire zoomed scene should get saved as an image. But even the scene items are zoomed in, and then saving image I am getting image of initial zoom scale.
What is the solution for this ??
Re: QGraphicsView/Scene to png image
The scene object is not a visible object.
It only holds information about the proportions of its consents (very simply put).
If you want the whole scene in the QImage, and you want it scaled, then resize the QImage.