From 7d2361b9da5c1ee9ef0724917108d6a3294e14c2 Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Thu, 14 Jul 2022 12:08:16 +0200 Subject: [PATCH] Addressbook example: port to QLatin1StringView MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows to fix the warning: qtbase/examples/widgets/itemviews/addressbook/addresswidget.cpp:115: warning: loop variable ‘str’ of type ‘const QString&’ binds to a temporary constructed from type ‘const char* const’ [-Wrange-loop-construct] Pick-to: 6.4 Change-Id: Ibbfa7f9e85fe9ef79291f9da3d161667286b282e Reviewed-by: Sona Kurazyan --- examples/widgets/itemviews/addressbook/addresswidget.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/widgets/itemviews/addressbook/addresswidget.cpp b/examples/widgets/itemviews/addressbook/addresswidget.cpp index de6b57e9d7..955a766750 100644 --- a/examples/widgets/itemviews/addressbook/addresswidget.cpp +++ b/examples/widgets/itemviews/addressbook/addresswidget.cpp @@ -110,10 +110,12 @@ void AddressWidget::removeEntry() //! [1] void AddressWidget::setupTabs() { - const auto groups = { "ABC", "DEF", "GHI", "JKL", "MNO", "PQR", "STU", "VW", "XYZ" }; + using namespace Qt::StringLiterals; + const auto groups = { "ABC"_L1, "DEF"_L1, "GHI"_L1, "JKL"_L1, "MNO"_L1, "PQR"_L1, + "STU"_L1, "VW"_L1, "XYZ"_L1 }; - for (const QString &str : groups) { - const auto regExp = QRegularExpression(QString("^[%1].*").arg(str), + for (QLatin1StringView str : groups) { + const auto regExp = QRegularExpression(QLatin1StringView("^[%1].*").arg(str), QRegularExpression::CaseInsensitiveOption); auto proxyModel = new QSortFilterProxyModel(this);