title: How to render a part of QGraphicsScene and save It as image file PyQt5
body: <p>Suppose I have <code>QGraphicsPixmapItem</code> from loaded image which is added to <code>QGraphicsScene</code>. And suppose I'll add several <code>QGraphicsPolygonItem</code>'s on scene. How I can render a part of the scene as <strong>full-size image both with polygons that are not in blank area</strong> and <strong>save</strong> this area <strong>as image file.</strong> </p>
  
  <pre><code>class ImageView(QtWidgets.QGraphicsView):
  
      def __init__(self, parent):
          super(ImageView, self).__init__(parent)
          self.setFocus()
          self._zoom = 0
          self._empty = True
          self.scene = QtWidgets.QGraphicsScene(self)
          self._image = QGraphicsPixmapItem()
          self.scene.addItem(self._image)
          self.setScene(self.scene)
  
          # some other actions
          foo()
  
      def fitInView(self):
          # custom fit in view and scaling
          bar()
  
  
      # some other methods
  
  class MainWindow(QtWidgets.QWidget):
      def __init__(self):
          self.viewer = ImageView(self)
          foo()
  
      def _save_image(self):
          # method that I need to implement
          pass
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/jzgRs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jzgRs.png" alt="GUI Example"></a></p>