[844] | 1 | /****************************************************************************
|
---|
| 2 | **
|
---|
| 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
| 4 | ** All rights reserved.
|
---|
| 5 | ** Contact: Nokia Corporation (qt-info@nokia.com)
|
---|
| 6 | **
|
---|
| 7 | ** This file is part of the documentation of the Qt Toolkit.
|
---|
| 8 | **
|
---|
| 9 | ** $QT_BEGIN_LICENSE:FDL$
|
---|
| 10 | ** Commercial Usage
|
---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in a
|
---|
| 14 | ** written agreement between you and Nokia.
|
---|
| 15 | **
|
---|
| 16 | ** GNU Free Documentation License
|
---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Free
|
---|
| 18 | ** Documentation License version 1.3 as published by the Free Software
|
---|
| 19 | ** Foundation and appearing in the file included in the packaging of this
|
---|
| 20 | ** file.
|
---|
| 21 | **
|
---|
| 22 | ** If you have questions regarding the use of this file, please contact
|
---|
| 23 | ** Nokia at qt-info@nokia.com.
|
---|
| 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 | For example, this registers a C++ class \c MySliderItem as a QML type
|
---|
| 89 | named \c Slider for version 1.0 of a \l{QML Modules}{module} called
|
---|
| 90 | "com.mycompany.qmlcomponents":
|
---|
| 91 |
|
---|
| 92 | \code
|
---|
| 93 | #include <QtDeclarative>
|
---|
| 94 |
|
---|
| 95 | ...
|
---|
| 96 |
|
---|
| 97 | qmlRegisterType<MySliderItem>("com.mycompany.qmlcomponents", 1, 0, "Slider");
|
---|
| 98 | \endcode
|
---|
| 99 |
|
---|
| 100 | Once this is registered, the type can be used in QML by importing the
|
---|
| 101 | specified module name and version number:
|
---|
| 102 |
|
---|
| 103 | \qml
|
---|
| 104 | import com.mycompany.qmlcomponents 1.0
|
---|
| 105 |
|
---|
| 106 | Slider { ... }
|
---|
| 107 | \endqml
|
---|
| 108 |
|
---|
| 109 | Note that it's perfectly reasonable for a library to register types to older versions
|
---|
| 110 | than the actual version of the library. Indeed, it is normal for the new library to allow
|
---|
| 111 | QML written to previous versions to continue to work, even if more advanced versions of
|
---|
| 112 | some of its types are available.
|
---|
| 113 | */
|
---|
| 114 |
|
---|
| 115 | /*!
|
---|
| 116 | \fn int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& message)
|
---|
| 117 | \relates QDeclarativeEngine
|
---|
| 118 |
|
---|
| 119 | This template function registers the C++ type in the QML system with
|
---|
| 120 | the name \a qmlName, in the library imported from \a uri having the
|
---|
| 121 | version number composed from \a versionMajor and \a versionMinor.
|
---|
| 122 |
|
---|
| 123 | While the type has a name and a type, it cannot be created, and the
|
---|
| 124 | given error \a message will result if creation is attempted.
|
---|
| 125 |
|
---|
| 126 | This is useful where the type is only intended for providing attached properties or enum values.
|
---|
| 127 |
|
---|
| 128 | Returns the QML type id.
|
---|
| 129 |
|
---|
| 130 | #include <QtDeclarative> to use this function.
|
---|
| 131 |
|
---|
| 132 | \sa qmlRegisterTypeNotAvailable()
|
---|
| 133 | */
|
---|
| 134 |
|
---|
| 135 | /*!
|
---|
| 136 | \fn int qmlRegisterTypeNotAvailable(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& message)
|
---|
| 137 | \relates QDeclarativeEngine
|
---|
| 138 |
|
---|
| 139 | This function registers a type in the QML system with the name \a qmlName, in the library imported from \a uri having the
|
---|
| 140 | version number composed from \a versionMajor and \a versionMinor, but any attempt to instantiate the type
|
---|
| 141 | will produce the given error \a message.
|
---|
| 142 |
|
---|
| 143 | Normally, the types exported by a module should be fixed. However, if a C++ type is not available, you should
|
---|
| 144 | at least "reserve" the QML type name, and give the user of your module a meaningful error message.
|
---|
| 145 |
|
---|
| 146 | Returns the QML type id.
|
---|
| 147 |
|
---|
| 148 | Example:
|
---|
| 149 |
|
---|
| 150 | \code
|
---|
| 151 | #ifdef NO_GAMES_ALLOWED
|
---|
| 152 | qmlRegisterTypeNotAvailable("MinehuntCore", 0, 1, "Game", "Get back to work, slacker!");
|
---|
| 153 | #else
|
---|
| 154 | qmlRegisterType<MinehuntGame>("MinehuntCore", 0, 1, "Game");
|
---|
| 155 | #endif
|
---|
| 156 | \endcode
|
---|
| 157 |
|
---|
| 158 | This will cause any QML which uses this module and attempts to use the type to produce an error message:
|
---|
| 159 | \code
|
---|
| 160 | fun.qml: Get back to work, slacker!
|
---|
| 161 | Game {
|
---|
| 162 | ^
|
---|
| 163 | \endcode
|
---|
| 164 |
|
---|
| 165 | Without this, a generic "Game is not a type" message would be given.
|
---|
| 166 |
|
---|
| 167 | #include <QtDeclarative> to use this function.
|
---|
| 168 |
|
---|
| 169 | \sa qmlRegisterUncreatableType()
|
---|
| 170 | */
|
---|
| 171 |
|
---|
| 172 | /*!
|
---|
| 173 | \fn int qmlRegisterType()
|
---|
| 174 | \relates QDeclarativeEngine
|
---|
| 175 | \overload
|
---|
| 176 |
|
---|
| 177 | This template function registers the C++ type in the QML
|
---|
| 178 | system. Instances of this type cannot be created from the QML
|
---|
| 179 | system.
|
---|
| 180 |
|
---|
| 181 | #include <QtDeclarative> to use this function.
|
---|
| 182 |
|
---|
| 183 | Returns the QML type id.
|
---|
| 184 | */
|
---|
| 185 |
|
---|
| 186 | /*!
|
---|
| 187 | \fn int qmlRegisterInterface(const char *typeName)
|
---|
| 188 | \relates QDeclarativeEngine
|
---|
| 189 |
|
---|
| 190 | This template function registers the C++ type in the QML system
|
---|
| 191 | under the name \a typeName.
|
---|
| 192 |
|
---|
| 193 | #include <QtDeclarative> to use this function.
|
---|
| 194 |
|
---|
| 195 | Returns the QML type id.
|
---|
| 196 | */
|
---|