c++ - How to print content of a QGraphicsView -


How can I print the contents of QGraphicsView in QT?

Thank you very much.

Take a look at official QT documentation:

For further reference: < / P>

"Graphics provides single-line printing through its rendering functions, QGraphicsScene :: render () and QGraphicsView :: render () The function provides the same API: You can pass QPainter to any color device. Print the whole scene in a full page by using the QPrinter .

Example:

  QGraphicsScene view; Scene.addRect (QRectF (0, 0, 100, 200), QPen (Qt :: black), QBrush (Qt :: green) ;); QPrinter Printer;; (QPrintDialog (and printer). Exec () == QDialog :: Approved) {CoPenator (and printer); painter.setRenderHint (QPainter :: Antialiasing); scene.render (& painter) ;}  

Comments