1/**************************************************************************** 2** 3** Copyright (C) 2015 The Qt Company Ltd. 4** Contact: http://www.qt.io/licensing/ 5** 6** This file is part of the documentation of the Qt Toolkit. 7** 8** $QT_BEGIN_LICENSE:FDL$ 9** Commercial License Usage 10** Licensees holding valid commercial Qt licenses may use this file in 11** accordance with the commercial license agreement provided with the 12** Software or, alternatively, in accordance with the terms contained in 13** a written agreement between you and The Qt Company. For licensing terms 14** and conditions see http://www.qt.io/terms-conditions. For further 15** information use the contact form at http://www.qt.io/contact-us. 16** 17** GNU Free Documentation License Usage 18** Alternatively, this file may be used under the terms of the GNU Free 19** Documentation License version 1.3 as published by the Free Software 20** Foundation and appearing in the file included in the packaging of 21** this file. Please review the following information to ensure 22** the GNU Free Documentation License version 1.3 requirements 23** will be met: http://www.gnu.org/copyleft/fdl.html. 24** $QT_END_LICENSE$ 25** 26****************************************************************************/ 27 28/*! 29 \module QtDeclarative 30 \title Qt Declarative Module 31 \ingroup modules 32 33 \brief The Qt Declarative module provides a declarative framework 34 for building highly dynamic, custom user interfaces. 35 36 To include the definitions of the module's classes, use the 37 following directive: 38 39 \code 40 #include <QtDeclarative> 41 \endcode 42 43 To link against the module, add this line to your \l qmake \c 44 .pro file: 45 46 \code 47 QT += declarative 48 \endcode 49 50 For more information on the Qt Declarative module, see the 51 \l{Qt Quick} documentation. 52*/ 53 54 55/*! 56 \macro QML_DECLARE_TYPE() 57 \relates QDeclarativeEngine 58 59 Equivalent to \c Q_DECLARE_METATYPE(TYPE *) and \c Q_DECLARE_METATYPE(QDeclarativeListProperty<TYPE>) 60 61 #include <QtDeclarative> to use this macro. 62*/ 63 64/*! 65 \macro QML_DECLARE_TYPEINFO(Type,Flags) 66 \relates QDeclarativeEngine 67 68 Declares additional properties of the given \a Type as described by the 69 specified \a Flags. 70 71 Current the only supported type info is \c QML_HAS_ATTACHED_PROPERTIES which 72 declares that the \a Type supports \l {Attached Properties}. 73 74 #include <QtDeclarative> to use this macro. 75*/ 76 77 78/*! 79 \fn int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName) 80 \relates QDeclarativeEngine 81 82 This template function registers the C++ type in the QML system with 83 the name \a qmlName, in the library imported from \a uri having the 84 version number composed from \a versionMajor and \a versionMinor. 85 86 Returns the QML type id. 87 88 There are two forms of this template function: 89 90 \code 91 template<typename T> 92 int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName); 93 94 template<typename T, int metaObjectRevision> 95 int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName); 96 \endcode 97 98 The former is the standard form which registers the type \e T as a new type. 99 The latter allows a particular revision of a class to be registered in 100 a specified version (see \l {QML Type Versioning}). 101 102 103 For example, this registers a C++ class \c MySliderItem as a QML type 104 named \c Slider for version 1.0 of a \l{QML Modules}{module} called 105 "com.mycompany.qmlcomponents": 106 107 \code 108 #include <QtDeclarative> 109 110 ... 111 112 qmlRegisterType<MySliderItem>("com.mycompany.qmlcomponents", 1, 0, "Slider"); 113 \endcode 114 115 Once this is registered, the type can be used in QML by importing the 116 specified module name and version number: 117 118 \qml 119 import com.mycompany.qmlcomponents 1.0 120 121 Slider { 122 // ... 123 } 124 \endqml 125 126 Note that it's perfectly reasonable for a library to register types to older versions 127 than the actual version of the library. Indeed, it is normal for the new library to allow 128 QML written to previous versions to continue to work, even if more advanced versions of 129 some of its types are available. 130*/ 131 132/*! 133 \fn int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& message) 134 \relates QDeclarativeEngine 135 136 This template function registers the C++ type in the QML system with 137 the name \a qmlName, in the library imported from \a uri having the 138 version number composed from \a versionMajor and \a versionMinor. 139 140 While the type has a name and a type, it cannot be created, and the 141 given error \a message will result if creation is attempted. 142 143 This is useful where the type is only intended for providing attached properties or enum values. 144 145 Returns the QML type id. 146 147 #include <QtDeclarative> to use this function. 148 149 \sa qmlRegisterTypeNotAvailable() 150*/ 151 152/*! 153 \fn int qmlRegisterTypeNotAvailable(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& message) 154 \relates QDeclarativeEngine 155 156 This function registers a type in the QML system with the name \a qmlName, in the library imported from \a uri having the 157 version number composed from \a versionMajor and \a versionMinor, but any attempt to instantiate the type 158 will produce the given error \a message. 159 160 Normally, the types exported by a module should be fixed. However, if a C++ type is not available, you should 161 at least "reserve" the QML type name, and give the user of your module a meaningful error message. 162 163 Returns the QML type id. 164 165 Example: 166 167 \code 168 #ifdef NO_GAMES_ALLOWED 169 qmlRegisterTypeNotAvailable("MinehuntCore", 0, 1, "Game", "Get back to work, slacker!"); 170 #else 171 qmlRegisterType<MinehuntGame>("MinehuntCore", 0, 1, "Game"); 172 #endif 173 \endcode 174 175 This will cause any QML which uses this module and attempts to use the type to produce an error message: 176 \code 177 fun.qml: Get back to work, slacker! 178 Game { 179 ^ 180 \endcode 181 182 Without this, a generic "Game is not a type" message would be given. 183 184 #include <QtDeclarative> to use this function. 185 186 \sa qmlRegisterUncreatableType() 187*/ 188 189/*! 190 \fn int qmlRegisterType() 191 \relates QDeclarativeEngine 192 \overload 193 194 This template function registers the C++ type in the QML 195 system. Instances of this type cannot be created from the QML 196 system. 197 198 #include <QtDeclarative> to use this function. 199 200 Returns the QML type id. 201*/ 202 203/*! 204 \fn int qmlRegisterInterface(const char *typeName) 205 \relates QDeclarativeEngine 206 207 This template function registers the C++ type in the QML system 208 under the name \a typeName. 209 210 #include <QtDeclarative> to use this function. 211 212 Returns the QML type id. 213*/ 214