From df39627fa33392a71ab79aadaa57e5c5e650e79e Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Tue, 1 Jan 2019 15:18:57 +0100 Subject: Examples: cleanup foreach usage Replace deprecated foreach macro with range-based for loop Change-Id: If919ba1d1d4acddfc1c5460ce7aebf8c49e3ac38 Reviewed-by: Paul Wicking --- examples/opengl/contextinfo/widget.cpp | 2 +- examples/opengl/legacy/overpainting/glwidget.cpp | 2 +- examples/opengl/qopenglwidget/glwidget.cpp | 6 +++--- examples/opengl/qopenglwidget/mainwindow.cpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'examples/opengl') diff --git a/examples/opengl/contextinfo/widget.cpp b/examples/opengl/contextinfo/widget.cpp index a5d9e98bf8..b1b7076503 100644 --- a/examples/opengl/contextinfo/widget.cpp +++ b/examples/opengl/contextinfo/widget.cpp @@ -387,7 +387,7 @@ void Widget::renderWindowReady() QList extensionList = context->extensions().toList(); std::sort(extensionList.begin(), extensionList.end()); m_extensions->append(tr("Found %1 extensions:").arg(extensionList.count())); - Q_FOREACH (const QByteArray &ext, extensionList) + for (const QByteArray &ext : qAsConst(extensionList)) m_extensions->append(QString::fromLatin1(ext)); m_output->moveCursor(QTextCursor::Start); diff --git a/examples/opengl/legacy/overpainting/glwidget.cpp b/examples/opengl/legacy/overpainting/glwidget.cpp index 1ec7bd731c..f98d043c5c 100644 --- a/examples/opengl/legacy/overpainting/glwidget.cpp +++ b/examples/opengl/legacy/overpainting/glwidget.cpp @@ -201,7 +201,7 @@ void GLWidget::paintEvent(QPaintEvent *event) //! [10] QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); - foreach (Bubble *bubble, bubbles) { + for (Bubble *bubble : qAsConst(bubbles)) { if (bubble->rect().intersects(event->rect())) bubble->drawBubble(&painter); } diff --git a/examples/opengl/qopenglwidget/glwidget.cpp b/examples/opengl/qopenglwidget/glwidget.cpp index 3fe919f94b..946b2bec67 100644 --- a/examples/opengl/qopenglwidget/glwidget.cpp +++ b/examples/opengl/qopenglwidget/glwidget.cpp @@ -385,10 +385,10 @@ void GLWidget::paintGL() painter.endNativePainting(); - if (m_showBubbles) - foreach (Bubble *bubble, m_bubbles) { + if (m_showBubbles) { + for (Bubble *bubble : qAsConst(m_bubbles)) bubble->drawBubble(&painter); - } + } if (const int elapsed = m_time.elapsed()) { QString framesPerSecond; diff --git a/examples/opengl/qopenglwidget/mainwindow.cpp b/examples/opengl/qopenglwidget/mainwindow.cpp index 4bd123628f..6fab3df79e 100644 --- a/examples/opengl/qopenglwidget/mainwindow.cpp +++ b/examples/opengl/qopenglwidget/mainwindow.cpp @@ -176,7 +176,7 @@ void MainWindow::timerUsageChanged(bool enabled) m_timer->start(); } else { m_timer->stop(); - foreach (QOpenGLWidget *w, m_glWidgets) + for (QOpenGLWidget *w : qAsConst(m_glWidgets)) w->update(); } } -- cgit v1.2.3