aboutsummaryrefslogtreecommitdiffstats
path: root/examples/widgets/graphicsview/dragdroprobot/dragdroprobot.py
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-10-08 15:30:00 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-10-08 16:22:24 +0200
commita5c8bb4305f994fdaca11a642231ea60273bf553 (patch)
tree613cb90dd5ac6490543de3f95c83fd9c28bc72c3 /examples/widgets/graphicsview/dragdroprobot/dragdroprobot.py
parent2ed45ce8991408de91d7e02a2b80a09a2d9e5083 (diff)
Replace deprecated API in examples
- Replace qrand() by QRandomGenerator - Replace QMatrix by QTransform Task-number: PYSIDE-841 Task-number: PYSIDE-1339 Task-number: PYSIDE-904 Change-Id: I8609a9ce90a6df1cb7c7f1b9aab61695edf41a3f Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'examples/widgets/graphicsview/dragdroprobot/dragdroprobot.py')
-rw-r--r--examples/widgets/graphicsview/dragdroprobot/dragdroprobot.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/examples/widgets/graphicsview/dragdroprobot/dragdroprobot.py b/examples/widgets/graphicsview/dragdroprobot/dragdroprobot.py
index 68a54d552..73ca02dca 100644
--- a/examples/widgets/graphicsview/dragdroprobot/dragdroprobot.py
+++ b/examples/widgets/graphicsview/dragdroprobot/dragdroprobot.py
@@ -45,14 +45,17 @@ from PySide2 import QtCore, QtGui, QtWidgets
import dragdroprobot_rc
+def random(boundary):
+ return QtCore.QRandomGenerator.global_().bounded(boundary)
+
+
class ColorItem(QtWidgets.QGraphicsItem):
n = 0
def __init__(self):
super(ColorItem, self).__init__()
- self.color = QtGui.QColor(QtCore.qrand() % 256, QtCore.qrand() % 256,
- QtCore.qrand() % 256)
+ self.color = QtGui.QColor(random(256), random(256), random(256))
self.setToolTip(
"QColor(%d, %d, %d)\nClick and drag this color onto the robot!" %
@@ -87,7 +90,7 @@ class ColorItem(QtWidgets.QGraphicsItem):
drag.setMimeData(mime)
ColorItem.n += 1
- if ColorItem.n > 2 and QtCore.qrand() % 3 == 0:
+ if ColorItem.n > 2 and random(3) == 0:
image = QtGui.QImage(':/images/head.png')
mime.setImageData(image)
drag.setPixmap(QtGui.QPixmap.fromImage(image).scaled(30,40))
@@ -261,8 +264,6 @@ if __name__== '__main__':
app = QtWidgets.QApplication(sys.argv)
- QtCore.qsrand(QtCore.QTime(0, 0, 0).secsTo(QtCore.QTime.currentTime()))
-
scene = QtWidgets.QGraphicsScene(-200, -200, 400, 400)
for i in range(10):