1 | // Copyright (C) 2021 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #include <private/qqmlfinalizer_p.h> |
5 | |
6 | QT_BEGIN_NAMESPACE |
7 | |
8 | QQmlFinalizerHook::~QQmlFinalizerHook() = default; |
9 | |
10 | /*! |
11 | \class QQmlFinalizerHook |
12 | \internal |
13 | |
14 | QQmlFinalizerHook is an internal interface to run code after the current toplevel |
15 | component has been completed. |
16 | At first, this might look like QQmlParserStaus' componentComplete functionality |
17 | by another name - however there is a difference. To understand it, consider the |
18 | following QML file: |
19 | |
20 | \qml |
21 | import QtQuick |
22 | Item { |
23 | id: root |
24 | Rectangle { |
25 | id: rect |
26 | Rectangle { id: innerRect } |
27 | } |
28 | property Item it: Item {id: myItem } |
29 | } |
30 | \endqml |
31 | |
32 | This file will instantiate 4 (sub-)components: One for each of root, rect, innerRect |
33 | and myItem. If the component gets loaded in a synchronous way, each of their |
34 | componentComplete (if existent) would run directly one after another (in a non-specified |
35 | order). |
36 | |
37 | However, in the case of an asynchronous instantiation, e.g. via a loader, we might interrupt |
38 | the (sub-)component construction partway: There can be a delay between the various |
39 | componentComplete calls, and not all sub-components might have been constructed yet. |
40 | QQmlFinalizerHook::componentFinalized is instead called after all asynchronously instantiated |
41 | (sub-)components have been constructed. Notably, all bindings of those components have also |
42 | been set up. |
43 | |
44 | \note While the engine does not use qobject_cast, tooling still relies on the interface |
45 | being marked as such. Thus you should always use the Q_INTERFACES macro in classes deriving |
46 | from QQmlFinalizerHook. |
47 | */ |
48 | |
49 | /*! |
50 | \fn void QQmlFinalizerHook::componentFinalized() |
51 | |
52 | The customization point provided by this interface. See the class description for |
53 | why it is useful and how it compares to componentComplete. |
54 | |
55 | \sa QQmlParserStatus::componentComplete |
56 | |
57 | */ |
58 | |
59 | QT_END_NAMESPACE |
60 | |