diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2016-08-03 12:11:38 +0300 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2016-08-12 08:27:53 +0000 |
commit | b57f743c469f16f0c9ad5a9f0182454b74deff97 (patch) | |
tree | 1ad1d6709e810cbb1357006ac0431a7b00292714 /src/corelib/itemmodels/qstringlistmodel.cpp | |
parent | 4e24ff2e68f942db1d8f90de43dae8db410e706b (diff) |
QStringListModel: fix dataChanged's roles parameter
In QStringListModel, the display and the edit roles are synonyms,
so when one is changed, the other changes with it. However, in
setData() we only emitted a vector with just the role that was
passed in by the user.
Fix by always passing both roles, regardless of which one was used
to set the data.
Change-Id: I498e7cb33796fae266901817b01ad85d861d4bb4
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib/itemmodels/qstringlistmodel.cpp')
-rw-r--r-- | src/corelib/itemmodels/qstringlistmodel.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/corelib/itemmodels/qstringlistmodel.cpp b/src/corelib/itemmodels/qstringlistmodel.cpp index c6a1fac9c8..725b7356ea 100644 --- a/src/corelib/itemmodels/qstringlistmodel.cpp +++ b/src/corelib/itemmodels/qstringlistmodel.cpp @@ -181,7 +181,13 @@ bool QStringListModel::setData(const QModelIndex &index, const QVariant &value, if (index.row() >= 0 && index.row() < lst.size() && (role == Qt::EditRole || role == Qt::DisplayRole)) { lst.replace(index.row(), value.toString()); - emit dataChanged(index, index, QVector<int>() << role); + QVector<int> roles; + roles.reserve(2); + roles.append(Qt::DisplayRole); + roles.append(Qt::EditRole); + emit dataChanged(index, index, roles); + // once Q_COMPILER_UNIFORM_INIT can be used, change to: + // emit dataChanged(index, index, {Qt::DisplayRole, Qt::EditRole}); return true; } return false; |