cometyang
26th December 2007, 22:17
Hi, All.
I'm trying to export the GraphicsScene's content to Image File.
And I use the code example from the documentation.
QGraphicsScene scene;
scene.addRect(QRectF(0, 0, 100, 200), QPen(Qt::black), QBrush(Qt::green));
QPixmap pixmap;
QPainter painter(&pixmap);
painter.setRenderHint(QPainter::Antialiasing);
scene.render(&painter);
painter.end();
pixmap.save("scene.png");
However, it failed.
The error message show that:
QPainter::begin:Cannot paint on a null pixmap
QPainter::setRenderHint: Painter must be active to set rendering hints
....
Anyone know what's wrong with the example code(I already correct some error in the given documentation)
I use Qt 4.3.2 on Linux platform
I'm trying to export the GraphicsScene's content to Image File.
And I use the code example from the documentation.
QGraphicsScene scene;
scene.addRect(QRectF(0, 0, 100, 200), QPen(Qt::black), QBrush(Qt::green));
QPixmap pixmap;
QPainter painter(&pixmap);
painter.setRenderHint(QPainter::Antialiasing);
scene.render(&painter);
painter.end();
pixmap.save("scene.png");
However, it failed.
The error message show that:
QPainter::begin:Cannot paint on a null pixmap
QPainter::setRenderHint: Painter must be active to set rendering hints
....
Anyone know what's wrong with the example code(I already correct some error in the given documentation)
I use Qt 4.3.2 on Linux platform