summaryrefslogtreecommitdiffstats
path: root/examples/widgets/graphicsview/elasticnodes/graphwidget.cpp
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@qt.io>2019-04-16 16:32:08 +0200
committerTobias Hunger <tobias.hunger@qt.io>2019-04-16 16:32:08 +0200
commit6630937e63ae5797487b86743a7733c8ae5cc42c (patch)
tree3d53dacf6430f9099e1fb20835881205de674961 /examples/widgets/graphicsview/elasticnodes/graphwidget.cpp
parent37ed6dae00640f9cc980ffda05347c12a7eb5d7e (diff)
parentc7af193d2e49e9f10b86262e63d8d13abf72b5cf (diff)
Merge commit 'dev' into 'wip/cmake-merge'
Diffstat (limited to 'examples/widgets/graphicsview/elasticnodes/graphwidget.cpp')
-rw-r--r--examples/widgets/graphicsview/elasticnodes/graphwidget.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/examples/widgets/graphicsview/elasticnodes/graphwidget.cpp b/examples/widgets/graphicsview/elasticnodes/graphwidget.cpp
index 81928a4ee1..6b817b2a21 100644
--- a/examples/widgets/graphicsview/elasticnodes/graphwidget.cpp
+++ b/examples/widgets/graphicsview/elasticnodes/graphwidget.cpp
@@ -164,16 +164,17 @@ void GraphWidget::timerEvent(QTimerEvent *event)
Q_UNUSED(event);
QList<Node *> nodes;
- foreach (QGraphicsItem *item, scene()->items()) {
+ const QList<QGraphicsItem *> items = scene()->items();
+ for (QGraphicsItem *item : items) {
if (Node *node = qgraphicsitem_cast<Node *>(item))
nodes << node;
}
- foreach (Node *node, nodes)
+ for (Node *node : qAsConst(nodes))
node->calculateForces();
bool itemsMoved = false;
- foreach (Node *node, nodes) {
+ for (Node *node : qAsConst(nodes)) {
if (node->advancePosition())
itemsMoved = true;
}
@@ -246,7 +247,8 @@ void GraphWidget::scaleView(qreal scaleFactor)
void GraphWidget::shuffle()
{
- foreach (QGraphicsItem *item, scene()->items()) {
+ const QList<QGraphicsItem *> items = scene()->items();
+ for (QGraphicsItem *item : items) {
if (qgraphicsitem_cast<Node *>(item))
item->setPos(-150 + QRandomGenerator::global()->bounded(300), -150 + QRandomGenerator::global()->bounded(300));
}