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>
This commit is contained in:
Samuel Gaist 2017-01-21 23:15:21 +01:00
parent 9e933de7f2
commit 2d81968c3b

View File

@ -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;
}
}