#include #include #include #include int main(int argc, char **argv) { QApplication app(argc, argv); QGraphicsScene scene; QGraphicsRectItem * rectItem = scene.addRect(QRectF(0, 0, 100, 200), QPen(Qt::black), QBrush(Qt::green)); //Comment out the follownig line and it will not crash: rectItem->setCacheMode(QGraphicsItem::DeviceCoordinateCache); QPixmap pixmap(100,200); QPainter painter(&pixmap); painter.setRenderHint(QPainter::Antialiasing); scene.render(&painter); painter.end(); pixmap.save("scene.png"); return app.exec(); }