diff options
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2020-04-28 20:09:33 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2020-05-20 16:39:44 +0200
commit2a1d4206c00e70bc9ffb2f4ddc58822efc3ced91 (patch)
parentadcc0f1bd79d66ab2c5f9417c3ad26a258425e02 (diff)
HeaderView: always use headerdata from syncView model
When HeaderView has a syncView, it should always use the header data of the syncView as model, and not only when that model is an QAbstractTableModel. Otherwise you cannot use headerView together width models like e.g QFileSystemModel (which is a QAbstractItemModel). If HeaderView has a syncView, but its model doesn't contain header data, then just leave the header empty. The application must either assign an model explicit to HeaderView, or provide header data to the syncView model. Just transposing the model will just duplicate the data in the syncView, which looks wrong. Change-Id: Ie48e960be8bf9fdd3ed227d90c6efb6aabfd18b5 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> (cherry picked from commit 4fe04f107d829434420ef44446a97938affd3420) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
1 files changed, 2 insertions, 7 deletions
diff --git a/src/quicktemplates2/qquickheaderview.cpp b/src/quicktemplates2/qquickheaderview.cpp
index 5c465cc7..85291bcb 100644
--- a/src/quicktemplates2/qquickheaderview.cpp
+++ b/src/quicktemplates2/qquickheaderview.cpp
@@ -236,16 +236,11 @@ void QQuickHeaderViewBasePrivate::setModelImpl(const QVariant &newModel)
void QQuickHeaderViewBasePrivate::syncModel()
if (assignedSyncView && !m_modelExplicitlySetByUser) {
auto newModel = assignedSyncView->model();
- if (auto m = newModel.value<QAbstractTableModel *>()) {
+ if (auto m = newModel.value<QAbstractItemModel *>())
proxyModelSetter(q, m_headerDataProxyModel, m);
- } else if (orientation() == Qt::Horizontal) {
- if (auto m = newModel.value<QAbstractItemModel *>())
- proxyModelSetter(q, m_transposeProxyModel, m);
- } else {
- QQuickTableViewPrivate::setModelImpl(newModel);
- }