diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2024-12-17 10:40:47 +0100 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2025-02-06 09:56:05 +0100 |
| commit | 8f452f3d4d863f77f2b5054a4f17c25034b1b339 (patch) | |
| tree | 5ec81f0078f615e43dfb692de618eb5f4b42e6fa /examples/widgets/tutorials | |
| parent | 38912923dfa6ae6f119dec56b3b11ceedbc81e1b (diff) | |
Use new 6.9 API in examples
Task-number: PYSIDE-2862
Change-Id: I45f0cafa5276ed7c387b903962f2845a23c327e8
Reviewed-by: Ece Cinucen <ece.cinucen@qt.io>
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'examples/widgets/tutorials')
| -rw-r--r-- | examples/widgets/tutorials/cannon/t11.py | 13 | ||||
| -rw-r--r-- | examples/widgets/tutorials/cannon/t12.py | 13 | ||||
| -rw-r--r-- | examples/widgets/tutorials/cannon/t13.py | 13 | ||||
| -rw-r--r-- | examples/widgets/tutorials/cannon/t14.py | 15 |
4 files changed, 25 insertions, 29 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) diff --git a/examples/widgets/tutorials/cannon/t12.py b/examples/widgets/tutorials/cannon/t12.py index 4960797bc..c503f9d5e 100644 --- a/examples/widgets/tutorials/cannon/t12.py +++ b/examples/widgets/tutorials/cannon/t12.py @@ -10,7 +10,7 @@ import math import random from PySide6.QtCore import QPoint, QRect, QTime, 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, QLabel, QLCDNumber, QPushButton, QSlider, QVBoxLayout, QWidget) @@ -184,12 +184,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) diff --git a/examples/widgets/tutorials/cannon/t13.py b/examples/widgets/tutorials/cannon/t13.py index c9b8bd5d7..39912fd19 100644 --- a/examples/widgets/tutorials/cannon/t13.py +++ b/examples/widgets/tutorials/cannon/t13.py @@ -11,7 +11,7 @@ import random from PySide6.QtCore import (QPoint, QRect, QTime, 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, QLabel, QLCDNumber, QPushButton, QSizePolicy, QSlider, QVBoxLayout, QWidget) @@ -211,12 +211,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) diff --git a/examples/widgets/tutorials/cannon/t14.py b/examples/widgets/tutorials/cannon/t14.py index 00674189b..d78243489 100644 --- a/examples/widgets/tutorials/cannon/t14.py +++ b/examples/widgets/tutorials/cannon/t14.py @@ -11,8 +11,8 @@ import random from PySide6.QtCore import (QPoint, QRect, QTime, QTimer, QSize, Qt, Signal, Slot, qWarning) -from PySide6.QtGui import (QColor, QFont, QKeySequence, QPainter, QPalette, - QShortcut, QRegion, QTransform) +from PySide6.QtGui import (QColor, QFont, QKeySequence, QPainter, QPainterStateGuard, + QPalette, QShortcut, QRegion, QTransform) from PySide6.QtWidgets import (QApplication, QFrame, QGridLayout, QHBoxLayout, QLabel, QLCDNumber, QPushButton, QSizePolicy, QSlider, QVBoxLayout, QWidget) @@ -241,12 +241,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) |
