diff options
| author | Dheerendra Purohit <dheerendra@pthinks.com> | 2025-06-23 16:00:06 +0530 |
|---|---|---|
| committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2025-07-28 11:34:22 +0000 |
| commit | efc6a4da3bc7a12be44db526785fb5cd01a538b9 (patch) | |
| tree | 8b376f733e6138365bbc81b23a6cb90e3ecbda03 | |
| parent | 2cbea65847b626320fe465266207b8728bf9a7ff (diff) | |
Doc: Describe when Repeater.count doesn't match delegate instance count
Clarifies the known conditions when Repeater.count does not match the
actual number of delegate instances: if it doesn't have a visual parent
("set up correctly" was a bit vague, raising the question of whether
there are other forms of incorrectness), or because it's temporarily out
of sync during delegate instantiation/deletion. If you need more info,
monitor the signals and/or check itemAt().
Amends a6eac7e299016c9ee8742abffd780683adac3066
Pick-to: 6.8
Fixes: QTBUG-127955
Change-Id: I6862beb8d61b1cf8a747bdc3ad02226691e6c3eb
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 70e0daf318086ce293879dfbc25a61f2a7b34466)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 820a9c7f2feeaa44c9f32214e11d54d065471b99)
| -rw-r--r-- | src/quick/items/qquickrepeater.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/quick/items/qquickrepeater.cpp b/src/quick/items/qquickrepeater.cpp index 1ac370734f..6dc63a1841 100644 --- a/src/quick/items/qquickrepeater.cpp +++ b/src/quick/items/qquickrepeater.cpp @@ -334,11 +334,29 @@ void QQuickRepeater::setDelegate(QQmlComponent *delegate) /*! \qmlproperty int QtQuick::Repeater::count - This property holds the number of items in the model. + This property holds the number of items in the \l model. - \note The number of items in the model as reported by count may differ from - the number of created delegates if the Repeater is in the process of - instantiating delegates or is incorrectly set up. + The value of \c count does not always match the number of instantiated + \l {delegate}{delegates}; use \l itemAt() to check if a delegate at a given + index exists. It returns \c null if the delegate is not instantiated. + + \list + \li While the Repeater is in the process of instantiating delegates (at + startup, or because of \c model changes), the \l itemAdded signal is + emitted for each delegate created, and the \c count property changes + afterwards. + \li If the Repeater is not part of a completed + \l {Concepts - Visual Parent in Qt Quick}{visual hierarchy}, + \c count reflects the model size, but no delegates are created. + \li If the Repeater destroys delegates because of \c model changes, + the \l itemRemoved() signal is emitted for each, and the \c count + property changes afterwards. + \li If the Repeater is taken out of the visual hierarchy (for example by + setting \c {parent = null}), delegates are destroyed, the \l itemRemoved() + signal is emitted for each, but \c count does not change. + \endlist + + \sa itemAt(), itemAdded(), itemRemoved() */ int QQuickRepeater::count() const { |
