Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
aboutsummaryrefslogtreecommitdiffstats
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/elasticnodes.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/elasticnodes.py')
-rw-r--r--examples/widgets/graphicsview/elasticnodes.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/examples/widgets/graphicsview/elasticnodes.py b/examples/widgets/graphicsview/elasticnodes.py
index 48feffc85..f5d229b13 100644
--- a/examples/widgets/graphicsview/elasticnodes.py
+++ b/examples/widgets/graphicsview/elasticnodes.py
@@ -46,6 +46,10 @@ import math
from PySide2 import QtCore, QtGui, QtWidgets
+def random(boundary):
+ return QtCore.QRandomGenerator.global_().bounded(boundary)
+
+
class Edge(QtWidgets.QGraphicsItem):
Pi = math.pi
TwoPi = 2.0 * Pi
@@ -338,7 +342,7 @@ class GraphWidget(QtWidgets.QGraphicsView):
elif key == QtCore.Qt.Key_Space or key == QtCore.Qt.Key_Enter:
for item in self.scene().items():
if isinstance(item, Node):
- item.setPos(-150 + QtCore.qrand() % 300, -150 + QtCore.qrand() % 300)
+ item.setPos(-150 + random(300), -150 + random(300))
else:
QtWidgets.QGraphicsView.keyPressEvent(self, event)
@@ -405,7 +409,6 @@ class GraphWidget(QtWidgets.QGraphicsView):
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
- QtCore.qsrand(QtCore.QTime(0,0,0).secsTo(QtCore.QTime.currentTime()))
widget = GraphWidget()
widget.show()