diff options
Diffstat (limited to 'examples/widgets/tutorials/cannon/t11.py')
| -rw-r--r-- | examples/widgets/tutorials/cannon/t11.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/examples/widgets/tutorials/cannon/t11.py b/examples/widgets/tutorials/cannon/t11.py index 00ac2fc26..6ba2d1a19 100644 --- a/examples/widgets/tutorials/cannon/t11.py +++ b/examples/widgets/tutorials/cannon/t11.py @@ -9,7 +9,7 @@ import sys import math from PySide6.QtCore import QPoint, QRect, QTimer, Qt, Signal, Slot, qWarning -from PySide6.QtGui import QColor, QFont, QPainter, QPalette, QRegion +from PySide6.QtGui import QColor, QFont, QPainter, QPainterStateGuard, QPalette, QRegion from PySide6.QtWidgets import (QApplication, QGridLayout, QHBoxLayout, QLCDNumber, QPushButton, QSlider, QVBoxLayout, QWidget) @@ -138,12 +138,11 @@ class CannonField(QWidget): painter.setPen(Qt.PenStyle.NoPen) painter.setBrush(Qt.GlobalColor.blue) - painter.save() - painter.translate(0, self.height()) - painter.drawPie(QRect(-35, -35, 70, 70), 0, 90 * 16) - painter.rotate(-self._current_angle) - painter.drawRect(CannonField.barrel_rect) - painter.restore() + with QPainterStateGuard(painter): + painter.translate(0, self.height()) + painter.drawPie(QRect(-35, -35, 70, 70), 0, 90 * 16) + painter.rotate(-self._current_angle) + painter.drawRect(CannonField.barrel_rect) def cannon_rect(self): result = QRect(0, 0, 50, 50) |
