diff --git a/src/gui/doc/snippets/droparea.cpp b/src/gui/doc/snippets/droparea.cpp index 13cf540d5e..ff77a1609e 100644 --- a/src/gui/doc/snippets/droparea.cpp +++ b/src/gui/doc/snippets/droparea.cpp @@ -127,10 +127,10 @@ void DropArea::clear() QPixmap DropArea::extractPixmap(const QByteArray &data, const QString &format) { - QList imageFormats = QImageReader::supportedImageFormats(); + const QList imageFormats = QImageReader::supportedImageFormats(); QPixmap pixmap; - foreach (const QByteArray &imageFormat, imageFormats) { + for (const QByteArray &imageFormat : imageFormats) { if (format.mid(6) == QString(imageFormat)) { pixmap.loadFromData(data, imageFormat); break; diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp index 8cc1dfa7d0..a600aa3299 100644 --- a/src/gui/image/qiconloader.cpp +++ b/src/gui/image/qiconloader.cpp @@ -412,12 +412,12 @@ QThemeIconInfo QIconLoader::findIconHelper(const QString &themeName, // a massive amount of file stat (especially if the icon is not there) auto cache = theme.m_gtkCaches.at(i); if (cache->isValid()) { - auto result = cache->lookup(iconNameFallback); + const auto result = cache->lookup(iconNameFallback); if (cache->isValid()) { const QVector subDirsCopy = subDirs; subDirs.clear(); subDirs.reserve(result.count()); - foreach (const char *s, result) { + for (const char *s : result) { QString path = QString::fromUtf8(s); auto it = std::find_if(subDirsCopy.cbegin(), subDirsCopy.cend(), [&](const QIconDirInfo &info) { diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 46518e4701..632fe874a6 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1008,7 +1008,7 @@ QWindow *QGuiApplication::topLevelAt(const QPoint &pos) QScreen *windowScreen = Q_NULLPTR; // Find the window on the primary virtual desktop first - foreach (QScreen *screen, primaryScreens) { + for (QScreen *screen : primaryScreens) { if (screen->geometry().contains(pos)) { windowScreen = screen; break; diff --git a/src/gui/kernel/qhighdpiscaling_p.h b/src/gui/kernel/qhighdpiscaling_p.h index 8540460a54..50fb4d73ea 100644 --- a/src/gui/kernel/qhighdpiscaling_p.h +++ b/src/gui/kernel/qhighdpiscaling_p.h @@ -454,7 +454,7 @@ QVector fromNativePixels(const QVector &pixelValues, const QWindow *window return pixelValues; QVector pointValues; - foreach (const T& pixelValue, pixelValues) + for (const T &pixelValue : pixelValues) pointValues.append(pixelValue / QHighDpiScaling::factor(window)); return pointValues; } @@ -467,7 +467,7 @@ QVector toNativePixels(const QVector &pointValues, const QWindow *window) return pointValues; QVector pixelValues; - foreach (const T& pointValue, pointValues) + for (const T &pointValue : pointValues) pixelValues.append(pointValue * QHighDpiScaling::factor(window)); return pixelValues; } diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index c23dbbb3be..8a6eeb4cc9 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -1565,9 +1565,9 @@ QList QKeySequence::listFromString(const QString &str, SequenceFor { QList result; - QStringList strings = str.split(QLatin1String("; ")); + const QStringList strings = str.split(QLatin1String("; ")); result.reserve(strings.count()); - foreach (const QString &string, strings) { + for (const QString &string : strings) { result << fromString(string, format); } @@ -1586,7 +1586,7 @@ QString QKeySequence::listToString(const QList &list, SequenceForm { QString result; - foreach (const QKeySequence &sequence, list) { + for (const QKeySequence &sequence : list) { result += sequence.toString(format); result += QLatin1String("; "); } diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp index f5ddaa4bb7..abbd1fe999 100644 --- a/src/gui/kernel/qplatformwindow.cpp +++ b/src/gui/kernel/qplatformwindow.cpp @@ -554,9 +554,10 @@ static inline const QScreen *effectiveScreen(const QWindow *window) #ifndef QT_NO_CURSOR if (siblings.size() > 1) { const QPoint referencePoint = window->transientParent() ? window->transientParent()->geometry().center() : QCursor::pos(); - foreach (const QScreen *sibling, siblings) + for (const QScreen *sibling : siblings) { if (sibling->geometry().contains(referencePoint)) return sibling; + } } #endif return screen; diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp index ae6879cf84..0e17b2d803 100644 --- a/src/gui/kernel/qscreen.cpp +++ b/src/gui/kernel/qscreen.cpp @@ -364,10 +364,10 @@ QRect QScreen::availableGeometry() const QList QScreen::virtualSiblings() const { Q_D(const QScreen); - QList platformScreens = d->platformScreen->virtualSiblings(); + const QList platformScreens = d->platformScreen->virtualSiblings(); QList screens; screens.reserve(platformScreens.count()); - foreach (QPlatformScreen *platformScreen, platformScreens) + for (QPlatformScreen *platformScreen : platformScreens) screens << platformScreen->screen(); return screens; } diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index d17c9c08a8..2489974bb3 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -504,7 +504,7 @@ QList { QList newList; newList.reserve(pointList.size()); - foreach (const QTouchEvent::TouchPoint &pt, pointList) { + for (const QTouchEvent::TouchPoint &pt : pointList) { QWindowSystemInterface::TouchPoint p; p.id = pt.id(); p.flags = pt.flags(); @@ -928,7 +928,7 @@ static QList touchPointList(const QLi { QList newList; - Q_FOREACH (QTouchEvent::TouchPoint p, pointList) + for (const QTouchEvent::TouchPoint &p : pointList) newList.append(touchPoint(p)); return newList; diff --git a/src/gui/opengl/qopengl.cpp b/src/gui/opengl/qopengl.cpp index eadca7cedf..35b1ec3bcf 100644 --- a/src/gui/opengl/qopengl.cpp +++ b/src/gui/opengl/qopengl.cpp @@ -548,7 +548,7 @@ Q_GUI_EXPORT std::set *qgpu_features(const QString &filename) { const QSet features = QOpenGLConfig::gpuFeatures(QOpenGLConfig::Gpu::fromContext(), filename); std::set *result = new std::set; - foreach (const QString &feature, features) + for (const QString &feature : features) result->insert(feature.toUtf8()); return result; } diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp index e35db51e01..c1b2e10785 100644 --- a/src/gui/opengl/qopenglframebufferobject.cpp +++ b/src/gui/opengl/qopenglframebufferobject.cpp @@ -1156,7 +1156,7 @@ QVector QOpenGLFramebufferObject::textures() const if (d->format.samples() != 0) return ids; ids.reserve(d->colorAttachments.count()); - foreach (const QOpenGLFramebufferObjectPrivate::ColorAttachment &color, d->colorAttachments) + for (const auto &color : d->colorAttachments) ids.append(color.guard ? color.guard->id() : 0); return ids; } @@ -1240,7 +1240,7 @@ QVector QOpenGLFramebufferObject::sizes() const Q_D(const QOpenGLFramebufferObject); QVector sz; sz.reserve(d->colorAttachments.size()); - foreach (const QOpenGLFramebufferObjectPrivate::ColorAttachment &color, d->colorAttachments) + for (const auto &color : d->colorAttachments) sz.append(color.size); return sz; } diff --git a/src/gui/opengl/qopenglshaderprogram.cpp b/src/gui/opengl/qopenglshaderprogram.cpp index afdb1133ea..1e0abbfab9 100644 --- a/src/gui/opengl/qopenglshaderprogram.cpp +++ b/src/gui/opengl/qopenglshaderprogram.cpp @@ -728,7 +728,7 @@ QOpenGLShaderProgramPrivate::~QOpenGLShaderProgramPrivate() bool QOpenGLShaderProgramPrivate::hasShader(QOpenGLShader::ShaderType type) const { - foreach (QOpenGLShader *shader, shaders) { + for (QOpenGLShader *shader : shaders) { if (shader->shaderType() == type) return true; } diff --git a/src/gui/painting/qplatformbackingstore.cpp b/src/gui/painting/qplatformbackingstore.cpp index d35f1d00d1..9a3bde3fa3 100644 --- a/src/gui/painting/qplatformbackingstore.cpp +++ b/src/gui/painting/qplatformbackingstore.cpp @@ -252,7 +252,7 @@ static QRegion deviceRegion(const QRegion ®ion, QWindow *window, const QPoint QVector rects; const QVector regionRects = region.rects(); rects.reserve(regionRects.count()); - foreach (const QRect &rect, regionRects) + for (const QRect &rect : regionRects) rects.append(deviceRect(rect.translated(offset), window)); QRegion deviceRegion; diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 089104665f..898b268070 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -1831,7 +1831,7 @@ void QFont::insertSubstitutions(const QString &familyName, QFontSubst *fontSubst = globalFontSubst(); Q_ASSERT(fontSubst != 0); QStringList &list = (*fontSubst)[familyName.toLower()]; - foreach (const QString &substituteName, substituteNames) { + for (const QString &substituteName : substituteNames) { const QString lowerSubstituteName = substituteName.toLower(); if (!list.contains(lowerSubstituteName)) list.append(lowerSubstituteName); diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 81df8027a1..b15fc4c047 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -3341,7 +3341,7 @@ void QTextEngine::drawItemDecorationList(QPainter *painter, const ItemDecoration if (decorationList.isEmpty()) return; - foreach (const ItemDecoration &decoration, decorationList) { + for (const ItemDecoration &decoration : decorationList) { painter->setPen(decoration.pen); painter->drawLine(QLineF(decoration.x1, decoration.y, decoration.x2, decoration.y)); } diff --git a/src/gui/text/qtextoption.cpp b/src/gui/text/qtextoption.cpp index de466f7672..2eb025f412 100644 --- a/src/gui/text/qtextoption.cpp +++ b/src/gui/text/qtextoption.cpp @@ -153,7 +153,7 @@ void QTextOption::setTabArray(const QList &tabStops) QList tabs; QTextOption::Tab tab; tabs.reserve(tabStops.count()); - foreach (qreal pos, tabStops) { + for (qreal pos : tabStops) { tab.position = pos; tabs.append(tab); } diff --git a/src/gui/text/qzip.cpp b/src/gui/text/qzip.cpp index ca787d7136..4f43f73d41 100644 --- a/src/gui/text/qzip.cpp +++ b/src/gui/text/qzip.cpp @@ -1022,7 +1022,7 @@ bool QZipReader::extractAll(const QString &destinationDir) const // create directories first const QVector allFiles = fileInfoList(); - foreach (const FileInfo &fi, allFiles) { + for (const FileInfo &fi : allFiles) { const QString absPath = destinationDir + QDir::separator() + fi.filePath; if (fi.isDir) { if (!baseDir.mkpath(fi.filePath)) @@ -1033,7 +1033,7 @@ bool QZipReader::extractAll(const QString &destinationDir) const } // set up symlinks - foreach (const FileInfo &fi, allFiles) { + for (const FileInfo &fi : allFiles) { const QString absPath = destinationDir + QDir::separator() + fi.filePath; if (fi.isSymLink) { QString destination = QFile::decodeName(fileData(fi.filePath)); @@ -1051,7 +1051,7 @@ bool QZipReader::extractAll(const QString &destinationDir) const } } - foreach (const FileInfo &fi, allFiles) { + for (const FileInfo &fi : allFiles) { const QString absPath = destinationDir + QDir::separator() + fi.filePath; if (fi.isFile) { QFile f(absPath);