diff options
Diffstat (limited to 'examples/widgets/painting/plot/plot.py')
-rw-r--r-- | examples/widgets/painting/plot/plot.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/examples/widgets/painting/plot/plot.py b/examples/widgets/painting/plot/plot.py index a125c3253..30dc3e504 100644 --- a/examples/widgets/painting/plot/plot.py +++ b/examples/widgets/painting/plot/plot.py @@ -88,13 +88,11 @@ class PlotWidget(QWidget): self.update() def paintEvent(self, event): - painter = QPainter() - painter.begin(self) - rect = QRect(QPoint(0, 0), self.size()) - painter.fillRect(rect, Qt.white) - painter.translate(-self._points[0].x(), 0) - painter.drawPolyline(self._points) - painter.end() + with QPainter(self) as painter: + rect = QRect(QPoint(0, 0), self.size()) + painter.fillRect(rect, Qt.white) + painter.translate(-self._points[0].x(), 0) + painter.drawPolyline(self._points) if __name__ == "__main__": |