From 64b2eb7490f502feececec314eb215bbb7832858 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Tue, 4 Dec 2018 17:27:16 +0100 Subject: Cleanup Widgets examples - replace foreach Cleanup the Widget examples - replace foreach with a standard for loop Change-Id: I59cb2bf4494201f9f0228b07a8bb936ce40da46f Reviewed-by: Samuel Gaist Reviewed-by: Konstantin Shegunov Reviewed-by: Edward Welbourne Reviewed-by: Paul Wicking --- examples/widgets/widgets/scribble/mainwindow.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'examples/widgets/widgets/scribble') diff --git a/examples/widgets/widgets/scribble/mainwindow.cpp b/examples/widgets/widgets/scribble/mainwindow.cpp index 58dc42c076..44afa64b94 100644 --- a/examples/widgets/widgets/scribble/mainwindow.cpp +++ b/examples/widgets/widgets/scribble/mainwindow.cpp @@ -153,8 +153,9 @@ void MainWindow::createActions() openAct->setShortcuts(QKeySequence::Open); connect(openAct, &QAction::triggered, this, &MainWindow::open); - foreach (QByteArray format, QImageWriter::supportedImageFormats()) { - QString text = tr("%1...").arg(QString(format).toUpper()); + const QList imageFormats = QImageWriter::supportedImageFormats(); + for (const QByteArray &format : imageFormats) { + QString text = tr("%1...").arg(QString::fromLatin1(format).toUpper()); QAction *action = new QAction(text, this); action->setData(format); @@ -193,7 +194,7 @@ void MainWindow::createMenus() //! [15] //! [16] { saveAsMenu = new QMenu(tr("&Save As"), this); - foreach (QAction *action, saveAsActs) + for (QAction *action : qAsConst(saveAsActs)) saveAsMenu->addAction(action); fileMenu = new QMenu(tr("&File"), this); -- cgit v1.2.3