I am having problems rendering a scene for the second time. The first time I do a QGraphicsScene->render(...) it renders ok and I am able to save the QImage as a png file. However when I try the same again on the same scene but a different portion(using a new QPainter and a new QImage) I get partly garbled rendering. (a lot of horizontal stripes through the picture)

This is the piece of test code that does the rendering and creates an image. The second image created contains the garbled picture. (Also when I call this routine again both images get garbled)

Qt Code:
  1. QImage *img;
  2. QPainter *paint;
  3.  
  4. img = new QImage(QSize(960, 600), QImage::Format_ARGB32);
  5. paint = new QPainter(img);
  6. itsGraphicResourceScene->render(paint, QRectF(), QRectF(3070, 0, 960, 600));
  7. paint->end();
  8. img->save("test1.png", "png");
  9. delete img;
  10. delete paint;
  11.  
  12. img = new QImage(QSize(960, 600), QImage::Format_ARGB32);
  13. paint = new QPainter(img);
  14. itsGraphicResourceScene->render(paint, QRectF(), QRectF(3910, 0, 960, 600));
  15. paint->end();
  16. img->save("test2.png", "png");
  17. delete img;
  18. delete paint;
To copy to clipboard, switch view to plain text mode 

I have even tried to completely refresh the scene by using QGrahicsScene->clear() and then adding all graphic items again. With the same results. Also, I have tried creating a new scene and added the graphic items to it and rendered from that scene (with the same results...)

Unfortunately I am not able to add a screenshot because the forum only accepts an URL when inserting a image