summaryrefslogtreecommitdiffstats
path: root/examples/widgets
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2021-10-26 06:25:01 +0200
committerJoerg Bornemann <joerg.bornemann@qt.io>2021-10-27 16:34:44 +0200
commit9beae46b599be011aab9f44efc92d49309b72da3 (patch)
tree07ff897dfe78d352f2a2c6521534f505acbf2977 /examples/widgets
parentdece6f5840463ae2ddf927d65eb1b3680e34a547 (diff)
Fix treemodelcompleter example
All nodes in the view were at the top level due to a spurious trimmed() call. The condition in the indentation calculation was flipped, leading to a segfault. Also, the input data does not contain tabs. Remove the condition that checks for tabs altogether. This amends commit 3fede6cb547b783377e833c9b269d4cecfe47e61. Fixes: QTBUG-97727 Pick-to: 6.2 5.15 Change-Id: Ic5068ead755c4dae5f0607724ac7704cce03227c Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Diffstat (limited to 'examples/widgets')
-rw-r--r--examples/widgets/tools/treemodelcompleter/mainwindow.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/examples/widgets/tools/treemodelcompleter/mainwindow.cpp b/examples/widgets/tools/treemodelcompleter/mainwindow.cpp
index 44c5b1312a..0c6bb66103 100644
--- a/examples/widgets/tools/treemodelcompleter/mainwindow.cpp
+++ b/examples/widgets/tools/treemodelcompleter/mainwindow.cpp
@@ -206,7 +206,7 @@ QAbstractItemModel *MainWindow::modelFromFile(const QString &fileName)
QRegularExpression re("^\\s+");
while (!file.atEnd()) {
- const QString line = QString::fromUtf8(file.readLine()).trimmed();
+ const QString line = QString::fromUtf8(file.readLine());
const QString trimmedLine = line.trimmed();
if (trimmedLine.isEmpty())
continue;
@@ -218,7 +218,7 @@ QAbstractItemModel *MainWindow::modelFromFile(const QString &fileName)
level = 0;
} else {
const int capLen = match.capturedLength();
- level = line.startsWith(QLatin1Char('\t')) ? capLen / 4 : capLen;
+ level = capLen / 4;
}
if (level + 1 >= parents.size())
@@ -267,4 +267,3 @@ void MainWindow::updateContentsLabel(const QString &sep)
{
contentsLabel->setText(tr("Type path from model above with items at each level separated by a '%1'").arg(sep));
}
-