diff options
author | Samuel Gaist <samuel.gaist@edeltech.ch> | 2017-01-21 22:42:14 +0100 |
---|---|---|
committer | Samuel Gaist <samuel.gaist@edeltech.ch> | 2017-02-15 14:45:40 +0000 |
commit | d2e713f3fd591ca9879318f5691709a2cd362d1c (patch) | |
tree | e031e7ff7732b4d9859dbd46321e50ad109d91ea /examples | |
parent | 57a710467b123e11b651eec951eb87558ea40c25 (diff) |
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 <szehowe.koh@gmail.com>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/widgets/tools/codecs/mainwindow.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
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<QString, QTextCodec *> 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; |