From 55867c2f0016fc395f91a4df1c8ae32cbf2d11db Mon Sep 17 00:00:00 2001 From: "Tomasz Siekierda (sierdzio)" Date: Sun, 4 Aug 2013 12:12:26 +0200 Subject: [PATCH] Document parenting behaviour of delegates in QML ListView and Component. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit ListView: As delegates are instantiated in ListView, they are parented to views contentItem. This is now explicitly stated in the documentation. Component: Components are not derived from Items, so they cannot hook to anchors. Task-number: QTBUG-24822 Change-Id: I09e04fbcc01b2858c039d22f9600ef201a9a91ab Reviewed-by: Topi Reiniö Reviewed-by: Alan Alpert Reviewed-by: Jerome Pasion --- src/qml/qml/qqmlcomponent.cpp | 3 ++- src/quick/items/qquicklistview.cpp | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index e59116a..850ee53 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -231,7 +231,8 @@ static inline QString buildTypeNameForDebug(const QMetaObject *metaObject) because it is defined inside a \c Component. The component encapsulates the QML types within, as if they were defined in a separate QML file, and is not loaded until requested (in this case, by the - two \l Loader objects). + two \l Loader objects). Because Component is not derived from Item, you cannot + anchor anything to it. Defining a \c Component is similar to defining a \l {QML Document}{QML document}. A QML document has a single top-level item that defines the behaviors and diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp index d79f535..558fbcd 100644 --- a/src/quick/items/qquicklistview.cpp +++ b/src/quick/items/qquicklistview.cpp @@ -1690,6 +1690,7 @@ bool QQuickListViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExte The list view itself is a focus scope (see \l{Keyboard Focus in Qt Quick} for more details). Delegates are instantiated as needed and may be destroyed at any time. + They are parented to ListView's \l {Flickable::contentItem}{contentItem}, not to the view itself. State should \e never be stored in a delegate. ListView attaches a number of properties to the root item of the delegate, for example @@ -1862,6 +1863,7 @@ QQuickListView::~QQuickListView() alignment of items. \note Delegates are instantiated as needed and may be destroyed at any time. + They are parented to ListView's \l {Flickable::contentItem}{contentItem}, not to the view itself. State should \e never be stored in a delegate. */ /*! -- 2.7.4