From f03d38603926f85343669cb4c9a547183c9353fd Mon Sep 17 00:00:00 2001 From: Dheerendra Purohit Date: Fri, 18 Oct 2024 19:02:52 +0530 Subject: [PATCH] Add parameter for function call in QIdentityProxyModel This change ensures that the correct model index is passed to the sourceModel()->data() function when retrieving the DateRole value. Pick-to: 6.5 Fixes: QTBUG-70792 Change-Id: I66c9f2404533625f05dd51db2d9263287db6ee91 Reviewed-by: Giuseppe D'Angelo (cherry picked from commit f0d6bfb2426392060575dc61bfa698df7964bf5e) Reviewed-by: Qt Cherry-pick Bot --- .../snippets/code/src_gui_itemviews_qidentityproxymodel.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/doc/snippets/code/src_gui_itemviews_qidentityproxymodel.cpp b/src/corelib/doc/snippets/code/src_gui_itemviews_qidentityproxymodel.cpp index 4ef1891cdbf..e412670e2f7 100644 --- a/src/corelib/doc/snippets/code/src_gui_itemviews_qidentityproxymodel.cpp +++ b/src/corelib/doc/snippets/code/src_gui_itemviews_qidentityproxymodel.cpp @@ -16,7 +16,8 @@ class DateFormatProxyModel : public QIdentityProxyModel if (role != Qt::DisplayRole) return QIdentityProxyModel::data(index, role); - const QDateTime dateTime = sourceModel()->data(SourceClass::DateRole).toDateTime(); + const QModelIndex sourceIndex = mapToSource(index); + const QDateTime dateTime = sourceModel()->data(sourceIndex, SourceClass::DateRole).toDateTime(); return dateTime.toString(m_formatString); }