diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2017-04-03 13:35:26 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2017-04-03 13:35:30 +0200 |
commit | 0eeb7ada04cc81d0ab1b61747bdf92fd7c33e1ec (patch) | |
tree | be4d0201b81b098a2976e857b5c6642f9c96e6ac /src/qml/doc | |
parent | 349d3400c11c0ad1c9aaec01c44b174dbb6ebf9a (diff) | |
parent | e4894fe13d178b6aa8b5580b402df2d1b4f2615c (diff) |
Merge remote-tracking branch 'origin/dev' into wip/scenegraphng
Change-Id: I0cbb2ba4a00580e6a74a4e4085fc4eb06d0fadae
Diffstat (limited to 'src/qml/doc')
-rw-r--r-- | src/qml/doc/src/javascript/hostenvironment.qdoc | 13 | ||||
-rw-r--r-- | src/qml/doc/src/qmlfunctions.qdoc | 14 |
2 files changed, 22 insertions, 5 deletions
diff --git a/src/qml/doc/src/javascript/hostenvironment.qdoc b/src/qml/doc/src/javascript/hostenvironment.qdoc index 1e33f2f641..7e9a22f5d3 100644 --- a/src/qml/doc/src/javascript/hostenvironment.qdoc +++ b/src/qml/doc/src/javascript/hostenvironment.qdoc @@ -74,6 +74,19 @@ Note that QML makes the following modifications to native objects: \li Locale-aware conversion functions are added to the \l Date and \l Number prototypes. \endlist +In addition, QML also extends the behavior of the instanceof function to +allow for type checking against QML types. This means that you may use it to +verify that a variable is indeed the type you expect, for example: + +\qml + var v = something(); + if (!v instanceof Item) { + throw new TypeError("I need an Item type!"); + } + + ... +\endqml + \section1 JavaScript Environment Restrictions diff --git a/src/qml/doc/src/qmlfunctions.qdoc b/src/qml/doc/src/qmlfunctions.qdoc index a03c382ed5..834684fe6d 100644 --- a/src/qml/doc/src/qmlfunctions.qdoc +++ b/src/qml/doc/src/qmlfunctions.qdoc @@ -168,8 +168,9 @@ from \a uri having version number composed from \a versionMajor and \a versionMinor. - While the type has a name and a type, it cannot be created, and the - given error \a reason will result if creation is attempted. + While the type has a name and a type, it cannot be created. An error + message with the given \a reason is printed if the user attempts to + create an instance of this type. This is useful where the type is only intended for providing attached properties, enum values or an abstract base class with its extension. @@ -189,11 +190,14 @@ from \a uri having version number composed from \a versionMajor and \a versionMinor. - This function is useful to register Q_NAMESPACE namespaces. + An instance of the meta object cannot be created. An error message with + the given \a reason is printed if the user attempts to create it. + + This function is useful for registering Q_NAMESPACE namespaces. Returns the QML type id. - Example: + For example: \code namespace MyNamespace { @@ -209,7 +213,7 @@ qmlRegisterUncreatableMetaObject(MyNamespace::staticMetaObject, "io.qt", 1, 0, "MyNamespace", "Access to enums & flags only"); \endcode - Now on QML side you can use the registered enums: + On the QML side, you can now use the registered enums: \code Component.onCompleted: console.log(MyNamespace.Key2) \endcode |