diff options
author | Ulf Hermann <[email protected]> | 2025-03-03 14:52:50 +0100 |
---|---|---|
committer | Ulf Hermann <[email protected]> | 2025-03-04 21:14:30 +0100 |
commit | cb59f99d0bfde35b8401b6249e5696341f3f6f98 (patch) | |
tree | 61e9eb2911309aeaa2dfc588c78cb7daef2691f1 /src/quick/items/qquickitemview_p_p.h | |
parent | 18eca40c4c9e445e38a6869725f9adc89714045d (diff) |
QQuickItemView: Fix model creation
In setDelegate(), we want to create the model if it doesn't exist, not
if it's not ours. Otherwise we might overwrite a perfectly fine model
set by user code when creating a delegate.
Also warn when we cannot retain an explicitly set delegate because an
incompatible model was passed.
Pick-to: 6.9 6.8
Change-Id: I43635d4cc2fcd0f539e1cfdf742a7d941323c2fe
Reviewed-by: Shawn Rutledge <[email protected]>
Reviewed-by: Fabian Kosmale <[email protected]>
Diffstat (limited to 'src/quick/items/qquickitemview_p_p.h')
-rw-r--r-- | src/quick/items/qquickitemview_p_p.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/quick/items/qquickitemview_p_p.h b/src/quick/items/qquickitemview_p_p.h index b5d70c6d6f..5317d2cf8f 100644 --- a/src/quick/items/qquickitemview_p_p.h +++ b/src/quick/items/qquickitemview_p_p.h @@ -229,6 +229,16 @@ public: releaseItem(item, reusableFlag); } + QQmlDelegateModel *createDelegateModel(QQuickItemView *q) { + Q_ASSERT(model.isNull()); + QQmlDelegateModel *delegateModel = new QQmlDelegateModel(qmlContext(q), q); + model = delegateModel; + ownModel = true; + if (q->isComponentComplete()) + delegateModel->componentComplete(); + return delegateModel; + } + void emitCountChanged(); virtual QQuickItemViewAttached *getAttachedObject(const QObject *) const { return nullptr; } @@ -310,6 +320,7 @@ public: #endif bool delegateValidated : 1; bool isClearing : 1; + bool explicitDelegate: 1; protected: virtual Qt::Orientation layoutOrientation() const = 0; |