Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
topic.qdoc
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3/*!
4\page qtqml-typesystem-topic.html
5\title The QML Type System
6\brief Description of the QML type system
7
8The types which may be used in the definition of an object hierarchy in a QML
9document can come from various sources. They may be:
10
11\list
12\li provided natively by the QML language
13\li registered via C++ by QML modules
14\li provided as QML documents by QML modules
15\endlist
16
17Furthermore, application developers can provide their own types, either by
18registering C++ types directly, or by defining reusable components in QML
19documents which can then be imported.
20
21Wherever the type definitions come from, the engine will enforce type-safety
22for properties and instances of those types.
23
24
25\section1 QML Value Types
26
27The QML language has built-in support for various primitive types including
28integers, double-precision floating point numbers, strings, and boolean values.
29Objects may have properties of these types, and values of these types may be
30passed as arguments to methods of objects.
31
32See the \l{qtqml-typesystem-valuetypes.html}{QML Value Types} documentation for
33more information about value types.
34
35\section1 QML Object Types
36
37A QML object type is a type from which a QML object can be instantiated. QML
38object types are derived from \l QtObject, and are provided by QML modules.
39Applications can import these modules to use the object types they provide.
40The \c QtQuick module provides the most common object types needed to create
41user interfaces in QML.
42
43Finally, every QML document implicitly defines a QML object type, which can be
44re-used in other QML documents. See the documentation about
45\l{qtqml-typesystem-objecttypes.html}{object types in the QML type system} for
46in-depth information about object types.
47
48\section1 QML Sequence Types
49
50Sequence types can be used to store sequences of values or objects.
51
52See the documentation about
53\l{qtqml-typesystem-sequencetypes.html}{sequence types in the QML type system}
54for in-depth information about sequence types.
55
56\section1 QML Namespaces
57
58QML Namespaces can be used to expose enumerations from C++ namespaces.
59
60See the documentation about
61\l{qtqml-typesystem-namespaces.html}{namespaces in the QML type system}
62for in-depth information about namespaces.
63
64\section1 JavaScript Types
65
66JavaScript objects and arrays are supported by the QML engine. Any standard
67JavaScript type can be created and stored using the generic \l var type.
68
69For example, the standard \c Date and \c Array types are available, as below:
70
71\qml
72import QtQuick
73
74Item {
75 property var theArray: []
76 property var theDate: new Date()
77
78 Component.onCompleted: {
79 for (var i = 0; i < 10; i++)
80 theArray.push("Item " + i)
81 console.log("There are", theArray.length, "items in the array")
82 console.log("The time is", theDate.toUTCString())
83 }
84}
85\endqml
86
87See \l {qtqml-javascript-expressions.html}{JavaScript Expressions in QML Documents} for more details.
88
89
90*/