diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2019-06-19 10:35:27 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2019-06-19 08:38:14 +0000 |
commit | 86ec76db7ad5338c93d9ac3ebd25e155a7d3441c (patch) | |
tree | cc1038e4c376402a810b7e2023688439ce1a9722 /examples/speech/hello_speak/mainwindow.cpp | |
parent | e80a2764eae65743d3d6a3195c92fd3a3fee998a (diff) |
Eradicate Q_FOREACH loops and mark the module free of them
(and of Java-style iterators).
Q_FOREACH is scheduled for deprecation, or at the very least banned
from use in Qt code.
Change-Id: Ic9cb269fb4dc27d00d80d0a956cef4a7e1136544
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Diffstat (limited to 'examples/speech/hello_speak/mainwindow.cpp')
-rw-r--r-- | examples/speech/hello_speak/mainwindow.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/examples/speech/hello_speak/mainwindow.cpp b/examples/speech/hello_speak/mainwindow.cpp index 17619d2..351249e 100644 --- a/examples/speech/hello_speak/mainwindow.cpp +++ b/examples/speech/hello_speak/mainwindow.cpp @@ -62,7 +62,8 @@ MainWindow::MainWindow(QWidget *parent) // Populate engine selection list ui.engine->addItem("Default", QString("default")); - foreach (QString engine, QTextToSpeech::availableEngines()) + const auto engines = QTextToSpeech::availableEngines(); + for (const QString &engine : engines) ui.engine->addItem(engine, engine); ui.engine->setCurrentIndex(0); engineSelected(0); @@ -125,9 +126,9 @@ void MainWindow::engineSelected(int index) disconnect(ui.language, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &MainWindow::languageSelected); ui.language->clear(); // Populate the languages combobox before connecting its signal. - QVector<QLocale> locales = m_speech->availableLocales(); + const QVector<QLocale> locales = m_speech->availableLocales(); QLocale current = m_speech->locale(); - foreach (const QLocale &locale, locales) { + for (const QLocale &locale : locales) { QString name(QString("%1 (%2)") .arg(QLocale::languageToString(locale.language())) .arg(QLocale::countryToString(locale.country()))); @@ -171,7 +172,7 @@ void MainWindow::localeChanged(const QLocale &locale) m_voices = m_speech->availableVoices(); QVoice currentVoice = m_speech->voice(); - foreach (const QVoice &voice, m_voices) { + for (const QVoice &voice : qAsConst(m_voices)) { ui.voice->addItem(QString("%1 - %2 - %3").arg(voice.name()) .arg(QVoice::genderName(voice.gender())) .arg(QVoice::ageName(voice.age()))); |