c++ - Rendering a QGraphicsScene to QImage results in objects being placed on a side of QImage -
my qgraphicsscene
quite large, , qgraphicsview
fit small portion of it.
i print/save qgraphicsscene
outputview::outputview(qwidget *parent) : qgraphicsview(parent) {...} void outputview::savetoimage() { qimage image(scene()->scenerect().size().tosize(), qimage::format_mono); image.fill(qt::transparent); qpainter painter(&image); render(&painter); image.save("output.png"); }
of course experimenting, placing objects in center of viewport...
the saved image contains objects, location of objects on left side of image
input:
output: (screenshot windows photo viewer)
it seems image created correct size, viewport contents rendered - top left corner of viewport on top left corner of image, leaving rest of image empty.
why happening ? doing wrong ?
update:
trying
fitinview(scene()->scenerect());
results in viewport showing entire image, zoomed ... saved image still contains viewport (only tiny)
and answer in additional explanation.
i should have done
scene()->render(&painter);
i rendering viewport.... not scene
Comments
Post a Comment