The following works fine for me, I can see no difference with your code:
#include <QApplication>
#include <QImage>
#include <QPainter>
#include <QGraphicsScene>
int main(int argc, char** argv)
{
scene->setSceneRect(0, 0, 2, 2);
QImage img
(scene
->sceneRect
().
size().
toSize(),
QImage::Format_RGB32);
scene->render(&painter);
bool b = img.save("test.png");
Q_ASSERT(b);
return 0;
}
#include <QApplication>
#include <QImage>
#include <QPainter>
#include <QGraphicsScene>
int main(int argc, char** argv)
{
QApplication app(argc, argv);
QGraphicsScene* scene = new QGraphicsScene();
scene->setSceneRect(0, 0, 2, 2);
QImage img(scene->sceneRect().size().toSize(), QImage::Format_RGB32);
QPainter painter(&img);
scene->render(&painter);
bool b = img.save("test.png");
Q_ASSERT(b);
return 0;
}
To copy to clipboard, switch view to plain text mode
Bookmarks