From d2e713f3fd591ca9879318f5691709a2cd362d1c Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sat, 21 Jan 2017 22:42:14 +0100 Subject: Example: migrate the codecs example to use QRegularExpression Update the codecs example to use the new QRegularExpression class in place of the deprecated QRegExp. Change-Id: Ibd60b7256071f8166c4bf38e6a40935494c3cf3f Reviewed-by: Sze Howe Koh --- examples/widgets/tools/codecs/mainwindow.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'examples/widgets/tools/codecs') diff --git a/examples/widgets/tools/codecs/mainwindow.cpp b/examples/widgets/tools/codecs/mainwindow.cpp index 5e4810dd4d..28f904d1a7 100644 --- a/examples/widgets/tools/codecs/mainwindow.cpp +++ b/examples/widgets/tools/codecs/mainwindow.cpp @@ -138,7 +138,8 @@ void MainWindow::aboutToShowSaveAsMenu() void MainWindow::findCodecs() { QMap codecMap; - QRegExp iso8859RegExp("ISO[- ]8859-([0-9]+).*"); + QRegularExpression iso8859RegExp("^ISO[- ]8859-([0-9]+).*$"); + QRegularExpressionMatch match; foreach (int mib, QTextCodec::availableMibs()) { QTextCodec *codec = QTextCodec::codecForMib(mib); @@ -150,8 +151,8 @@ void MainWindow::findCodecs() rank = 1; } else if (sortKey.startsWith(QLatin1String("UTF-16"))) { rank = 2; - } else if (iso8859RegExp.exactMatch(sortKey)) { - if (iso8859RegExp.cap(1).size() == 1) + } else if ((match = iso8859RegExp.match(sortKey)).hasMatch()) { + if (match.captured(1).size() == 1) rank = 3; else rank = 4; -- cgit v1.2.3