From 86ec76db7ad5338c93d9ac3ebd25e155a7d3441c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 19 Jun 2019 10:35:27 +0200 Subject: 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 --- examples/speech/hello_speak/mainwindow.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'examples/speech/hello_speak/mainwindow.cpp') 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(&QComboBox::currentIndexChanged), this, &MainWindow::languageSelected); ui.language->clear(); // Populate the languages combobox before connecting its signal. - QVector locales = m_speech->availableLocales(); + const QVector 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()))); -- cgit v1.2.3