summaryrefslogtreecommitdiffstats
path: root/examples/widgets/graphicsview/elasticnodes/node.cpp
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2018-12-07 11:59:02 +0100
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2019-01-23 18:49:02 +0000
commit26f7edb09eaf66590de9a3603489464fd868eedc (patch)
treeb49374b0649421072494150d7ec6ff84f43fa051 /examples/widgets/graphicsview/elasticnodes/node.cpp
parentbce32c8ab8c547d0fc9d12d192546dde361443fa (diff)
Cleanup Widgets examples - foreach
Cleanup the Widgets examples - replace foreach with range-based for loop in graphicsview subdirectory Change-Id: I9093b3ae89d73d0b860d29929943881c90074bce Reviewed-by: Luca Beldi <v.ronin@yahoo.it> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Diffstat (limited to 'examples/widgets/graphicsview/elasticnodes/node.cpp')
-rw-r--r--examples/widgets/graphicsview/elasticnodes/node.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/examples/widgets/graphicsview/elasticnodes/node.cpp b/examples/widgets/graphicsview/elasticnodes/node.cpp
index 71737c984b..d4fa3d2b4f 100644
--- a/examples/widgets/graphicsview/elasticnodes/node.cpp
+++ b/examples/widgets/graphicsview/elasticnodes/node.cpp
@@ -94,7 +94,8 @@ void Node::calculateForces()
// Sum up all forces pushing this item away
qreal xvel = 0;
qreal yvel = 0;
- foreach (QGraphicsItem *item, scene()->items()) {
+ const QList<QGraphicsItem *> items = scene()->items();
+ for (QGraphicsItem *item : items) {
Node *node = qgraphicsitem_cast<Node *>(item);
if (!node)
continue;
@@ -113,7 +114,7 @@ void Node::calculateForces()
//! [4]
// Now subtract all forces pulling items together
double weight = (edgeList.size() + 1) * 10;
- foreach (Edge *edge, edgeList) {
+ for (const Edge *edge : qAsConst(edgeList)) {
QPointF vec;
if (edge->sourceNode() == this)
vec = mapToItem(edge->destNode(), 0, 0);
@@ -194,7 +195,7 @@ QVariant Node::itemChange(GraphicsItemChange change, const QVariant &value)
{
switch (change) {
case ItemPositionHasChanged:
- foreach (Edge *edge, edgeList)
+ for (Edge *edge : qAsConst(edgeList))
edge->adjust();
graph->itemMoved();
break;