I have application whith whidgets on mainform. I need to render one of widgets (qwtPlot) to QPixmap using QGraphicsScene. I use such code for that:
Qt Code:
  1. QPixmap pixmap(300, 300);
  2. QPainter painter(&pixmap);
  3. painter.fillRect(0, 0, 300, 300, Qt::black);
  4. QGraphicsProxyWidget *widget = scene->addWidget(qwtPlot);
  5. qwtPlot->repaint();
  6. qwtPlot->show();
  7. scene->render(&painter, QRectF(), QRect(), Qt::IgnoreAspectRatio);
  8. if (pixmap.save(QApplication::applicationDirPath() + "/image.png", "PNG"))
  9. {
  10. box.setText("Saved");
  11. box.exec();
  12. }
  13. delete widget;
  14. delete scene;
To copy to clipboard, switch view to plain text mode 

But I haven't any whidgets in "image.png" file - all file is black. Why my widget don't show in the file?