aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlfinalizer.cpp
blob: 8b87b8955dccc88e9e093212799b32db8933ae94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#include <private/qqmlfinalizer_p.h>

QT_BEGIN_NAMESPACE

QQmlFinalizerHook::~QQmlFinalizerHook() = default;

/*!
    \class QQmlFinalizerHook
    \internal

    QQmlFinalizerHook is an internal interface to run code after the current toplevel
    component has been completed.
    At first, this might look like QQmlParserStaus' componentComplete functionality
    by another name - however there is a difference. To understand it, consider the
    following QML file:

    \qml
    import QtQuick
    Item {
        id: root
        Rectangle {
            id: rect
            Rectangle { id: innerRect }
        }
        property Item it: Item {id: myItem }
    }
    \endqml

    This file will instantiate 4 (sub-)components: One for each of root, rect, innerRect
    and myItem. If the component gets loaded in a synchronous way, each of their
    componentComplete (if existent) would run directly one after another (in a non-specified
    order).

    However, in the case of an asynchronous instantiation, e.g. via a loader, we might interrupt
    the (sub-)component construction partway: There can be a delay between the various
    componentComplete calls, and not all sub-components might have been constructed yet.
    QQmlFinalizerHook::componentFinalized is instead called after all asynchronously instantiated
    (sub-)components have been constructed. Notably, all bindings of those components have also
    been set up.

    \note While the engine does not use qobject_cast, tooling still relies on the interface
    being marked as such. Thus you should always use the Q_INTERFACES macro in classes deriving
    from QQmlFinalizerHook.
*/

/*!
    \fn void QQmlFinalizerHook::componentFinalized()

    The customization point provided by this interface. See the class description for
    why it is useful and how it compares to componentComplete.

    \sa QQmlParserStatus::componentComplete

 */

QT_END_NAMESPACE