path: root/src
diff options
authorJan Kundrát <>2014-03-24 19:17:43 +0100
committerThe Qt Project <>2014-05-29 11:11:02 +0200
commit267ba8b63e0fbf02cde4d2709397ed0e12f34ee2 (patch)
tree88b667d6adcb0f93befdb19421fc3cab2fc87b83 /src
parent909b0de5d16f2af3b3d6a3ca4c7e53b84836ad37 (diff)
QAbstractProxyModel::sibling: treat row/column as offsets within the proxy
Qt5 allows QAIM subclasses to reimplement the sibling() method. Unfortunately, the default QAbstractProxyModel's reimplementation differs in behavior to what the Qt4 version was doing. In particular, the Qt4 version used to use the row and column as positions within the proxy model, while the Qt5 version mistakenly does this at the level of source model. This is arguably broken; the caller asks for a sibling of the proxy index, not for a sibling within the proxy model. This change makes the QAPM::sibling work explicitly in the same way as the Qt4 code behaved. The reimplementation of QAbstractProxyModel::sibling was introduced in 9dfba89c28bbff3316cb7aed6c07f90c0f2d5a22. It was subsequently fixed with commit 999109866dbd350a29cc70815d0c772545c85746 not to return indexes from the source model, but the logic was still different from the Qt4 version. [ChangeLog][QtCore][QAbstractProxyModel] Fixed QAbstractProxyModel::sibling to work in the same manner as the Qt4 code used to behave. Previously, Qt5's implementation would treat the row and column as positions in the source model instead of a position in the proxy itself. Followup-to 9dfba89c28bbff3316cb7aed6c07f90c0f2d5a22 and 999109866dbd350a29cc70815d0c772545c85746 Change-Id: Ia25027b2ad9e4777ba28de2d2226d48f8cccf587 Reviewed-by: Olivier Goffart <> Reviewed-by: Mark Brand <> Reviewed-by: Stephen Kelly <>
Diffstat (limited to 'src')
1 files changed, 1 insertions, 2 deletions
diff --git a/src/corelib/itemmodels/qabstractproxymodel.cpp b/src/corelib/itemmodels/qabstractproxymodel.cpp
index d435c4bcf5..2f1f4921f7 100644
--- a/src/corelib/itemmodels/qabstractproxymodel.cpp
+++ b/src/corelib/itemmodels/qabstractproxymodel.cpp
@@ -377,8 +377,7 @@ bool QAbstractProxyModel::hasChildren(const QModelIndex &parent) const
QModelIndex QAbstractProxyModel::sibling(int row, int column, const QModelIndex &idx) const
- Q_D(const QAbstractProxyModel);
- return mapFromSource(d->model->sibling(row, column, mapToSource(idx)));
+ return index(row, column, idx.parent());