summaryrefslogtreecommitdiffstats
path: root/examples/widgets/graphicsview/flowlayout
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/flowlayout
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/flowlayout')
-rw-r--r--examples/widgets/graphicsview/flowlayout/flowlayout.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/examples/widgets/graphicsview/flowlayout/flowlayout.cpp b/examples/widgets/graphicsview/flowlayout/flowlayout.cpp
index 065c3e00ea..ab6bbb7aa4 100644
--- a/examples/widgets/graphicsview/flowlayout/flowlayout.cpp
+++ b/examples/widgets/graphicsview/flowlayout/flowlayout.cpp
@@ -154,8 +154,7 @@ QSizeF FlowLayout::minSize(const QSizeF &constraint) const
} else if (constraint.height() >= 0) { // width for height?
// not supported
} else {
- QGraphicsLayoutItem *item;
- foreach (item, m_items)
+ for (const QGraphicsLayoutItem *item : qAsConst(m_items))
size = size.expandedTo(item->effectiveSizeHint(Qt::MinimumSize));
size += QSize(left + right, top + bottom);
}
@@ -167,10 +166,9 @@ QSizeF FlowLayout::prefSize() const
qreal left, right;
getContentsMargins(&left, 0, &right, 0);
- QGraphicsLayoutItem *item;
qreal maxh = 0;
qreal totalWidth = 0;
- foreach (item, m_items) {
+ for (const QGraphicsLayoutItem *item : qAsConst(m_items)) {
if (totalWidth > 0)
totalWidth += spacing(Qt::Horizontal);
QSizeF pref = item->effectiveSizeHint(Qt::PreferredSize);
@@ -187,10 +185,9 @@ QSizeF FlowLayout::prefSize() const
QSizeF FlowLayout::maxSize() const
{
- QGraphicsLayoutItem *item;
qreal totalWidth = 0;
qreal totalHeight = 0;
- foreach (item, m_items) {
+ for (const QGraphicsLayoutItem *item : qAsConst(m_items)) {
if (totalWidth > 0)
totalWidth += spacing(Qt::Horizontal);
if (totalHeight > 0)