diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-10-12 08:17:07 +0200 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-10-12 08:17:07 +0200 |
| commit | 30724622333ffc8bce61f7e19217977eebbf9564 (patch) | |
| tree | 172487d1478cc478857d46cb445db59ca3601448 /examples/widgets/graphicsview/elasticnodes.py | |
| parent | 1a66d7be29902fc041fe53ef280c237d3c3f216b (diff) | |
| parent | 8847a47aad95d7f85d5e184071bf95c44826c4c7 (diff) | |
Merge remote-tracking branch 'origin/5.15' into dev
Change-Id: I7f16e4f178bff9c37af3b7a9d536c5d6f42c66fb
Diffstat (limited to 'examples/widgets/graphicsview/elasticnodes.py')
| -rw-r--r-- | examples/widgets/graphicsview/elasticnodes.py | 7 |
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() |
