diff options
author | Samuel Gaist <samuel.gaist@edeltech.ch> | 2017-01-21 23:15:21 +0100 |
---|---|---|
committer | Samuel Gaist <samuel.gaist@edeltech.ch> | 2017-03-07 23:11:31 +0000 |
commit | 2d81968c3bbab42a03e0e64f4de92fea10968424 (patch) | |
tree | 6e1cfa11e0fe3bbff3cc2ea905ad001ee1a46a57 /examples/widgets | |
parent | 9e933de7f2f83946cc3926e4ea5ae0d8e4ce93bb (diff) | |
download | qtbase-2d81968c3bbab42a03e0e64f4de92fea10968424.tar.gz |
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 <szehowe.koh@gmail.com>
Diffstat (limited to 'examples/widgets')
-rw-r--r-- | examples/widgets/tools/treemodelcompleter/mainwindow.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
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; } } |