From 2d81968c3bbab42a03e0e64f4de92fea10968424 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sat, 21 Jan 2017 23:15:21 +0100 Subject: Example: migrate treemodelcompleter example to use QRegularExpression Update the treemodelcompleter example to use the new QRegularExpression class in place of the deprecated QRegExp. Change-Id: I9fa91ca6e847603de37019e4ca86fc69a51a3772 Reviewed-by: Sze Howe Koh --- examples/widgets/tools/treemodelcompleter/mainwindow.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'examples') diff --git a/examples/widgets/tools/treemodelcompleter/mainwindow.cpp b/examples/widgets/tools/treemodelcompleter/mainwindow.cpp index c00e058fc4..4aabb04023 100644 --- a/examples/widgets/tools/treemodelcompleter/mainwindow.cpp +++ b/examples/widgets/tools/treemodelcompleter/mainwindow.cpp @@ -194,16 +194,17 @@ QAbstractItemModel *MainWindow::modelFromFile(const QString& fileName) if (line.isEmpty() || trimmedLine.isEmpty()) continue; - QRegExp re("^\\s+"); - int nonws = re.indexIn(line); + QRegularExpression re("^\\s+"); + QRegularExpressionMatch match = re.match(line); + int nonws = match.capturedStart(); int level = 0; if (nonws == -1) { level = 0; } else { if (line.startsWith("\t")) { - level = re.cap(0).length(); + level = match.capturedLength(); } else { - level = re.cap(0).length()/4; + level = match.capturedLength()/4; } } -- cgit v1.2.3