From b57f743c469f16f0c9ad5a9f0182454b74deff97 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 3 Aug 2016 12:11:38 +0300 Subject: 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) --- src/corelib/itemmodels/qstringlistmodel.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/corelib/itemmodels') 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() << role); + QVector 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; -- cgit v1.2.3