1// Copyright (C) 2016 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 "qqmlparserstatus.h"
5
6QT_BEGIN_NAMESPACE
7
8/*!
9 \class QQmlParserStatus
10 \since 5.0
11 \inmodule QtQml
12 \brief The QQmlParserStatus class provides updates on the QML parser state.
13
14 QQmlParserStatus provides a mechanism for classes instantiated by
15 a QQmlEngine to receive notification at key points in their creation.
16
17 This class is often used for optimization purposes, as it allows you to defer an
18 expensive operation until after all the properties have been set on an
19 object. For example, QML's \l {Text} element uses the parser status
20 to defer text layout until all of its properties have been set (we
21 don't want to layout when the \c text is assigned, and then relayout
22 when the \c font is assigned, and relayout again when the \c width is assigned,
23 and so on).
24
25 Be aware that QQmlParserStatus methods are only called when a class is instantiated
26 by a QQmlEngine. If you create the same class directly from C++, these methods will
27 not be called automatically. To avoid this problem, it is recommended that you start
28 deferring operations from classBegin instead of from the initial creation of your class.
29 This will still prevent multiple revaluations during initial binding assignment in QML,
30 but will not defer operations invoked from C++.
31
32 To use QQmlParserStatus, you must inherit both a QObject-derived class
33 and QQmlParserStatus, and use the Q_INTERFACES() macro.
34
35 \snippet code/src_qml_qqmlparserstatus.cpp 0
36*/
37
38/*! \internal */
39QQmlParserStatus::QQmlParserStatus()
40: d(nullptr)
41{
42}
43
44/*! \internal */
45QQmlParserStatus::~QQmlParserStatus()
46{
47 if(d)
48 (*d) = nullptr;
49}
50
51/*!
52 \fn void QQmlParserStatus::classBegin()
53
54 Invoked after class creation, but before any properties have been set.
55*/
56
57/*!
58 \fn void QQmlParserStatus::componentComplete()
59
60 Invoked after the root component that caused this instantiation has
61 completed construction. At this point all static values and binding values
62 have been assigned to the class.
63*/
64
65QT_END_NAMESPACE
66

source code of qtdeclarative/src/qml/qml/qqmlparserstatus.cpp