diff options
Diffstat (limited to 'src/qml/doc/src')
-rw-r--r-- | src/qml/doc/src/cppintegration/data.qdoc | 2 | ||||
-rw-r--r-- | src/qml/doc/src/cppintegration/definetypes.qdoc | 4 | ||||
-rw-r--r-- | src/qml/doc/src/cppintegration/exposecppattributes.qdoc | 1 | ||||
-rw-r--r-- | src/qml/doc/src/cppintegration/topic.qdoc | 8 | ||||
-rw-r--r-- | src/qml/doc/src/qmlfunctions.qdoc | 2 | ||||
-rw-r--r-- | src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc | 41 |
6 files changed, 48 insertions, 10 deletions
diff --git a/src/qml/doc/src/cppintegration/data.qdoc b/src/qml/doc/src/cppintegration/data.qdoc index 9cc7291583..c3d073872a 100644 --- a/src/qml/doc/src/cppintegration/data.qdoc +++ b/src/qml/doc/src/cppintegration/data.qdoc @@ -370,7 +370,7 @@ properties: private: QString m_name; - } + }; Q_DECLARE_METATYPE(Actor) \endcode diff --git a/src/qml/doc/src/cppintegration/definetypes.qdoc b/src/qml/doc/src/cppintegration/definetypes.qdoc index 32084bd308..1ce00c6ad0 100644 --- a/src/qml/doc/src/cppintegration/definetypes.qdoc +++ b/src/qml/doc/src/cppintegration/definetypes.qdoc @@ -346,8 +346,8 @@ demonstrates a usage of extension objects. \section1 Defining QML-Specific Types and Attributes - -\section2 Providing Attached Objects for Data Annotations +\section2 Providing Attached Properties +\keyword Integrating QML and C++ - Attached Properties In the QML language syntax, there is a notion of \l{Attached properties and attached signal handlers}{\e {attached properties} and \e {attached signal diff --git a/src/qml/doc/src/cppintegration/exposecppattributes.qdoc b/src/qml/doc/src/cppintegration/exposecppattributes.qdoc index c4c58c2821..2121c1f291 100644 --- a/src/qml/doc/src/cppintegration/exposecppattributes.qdoc +++ b/src/qml/doc/src/cppintegration/exposecppattributes.qdoc @@ -301,6 +301,7 @@ Note that the template class type for the QQmlListProperty — in this case, \section2 Grouped Properties +\keyword Integrating QML and C++ - Grouped Properties Any read-only object-type property is accessible from QML code as a \e {grouped property}. This can be used to expose a group of related diff --git a/src/qml/doc/src/cppintegration/topic.qdoc b/src/qml/doc/src/cppintegration/topic.qdoc index 22115395b1..183af25297 100644 --- a/src/qml/doc/src/cppintegration/topic.qdoc +++ b/src/qml/doc/src/cppintegration/topic.qdoc @@ -46,13 +46,13 @@ BackEnd, in a QML application: \li Add a new C++ class called \c BackEnd to the project and replace its header file contents with: -\quotefile code/backend/backend.h +\snippet code/backend/backend.h backend_header The \c Q_PROPERTY macro declares a property that could be accessed from QML. \li Replace its C++ file contents with: -\quotefile code/backend/backend.cpp +\snippet code/backend/backend.cpp backend_cpp The \c setUserName function emits the \c userNameChanged signal every time \c m_userName value changes. The signal can be handled from QML using the @@ -61,14 +61,14 @@ The \c setUserName function emits the \c userNameChanged signal every time \li Include \c "backend.h" in \c main.cpp and register the class as a QML type under a import URL as shown below: -\quotefile code/backend/main.cpp +\snippet code/backend/main.cpp main_cpp The BackEnd class is registered as a type, which is accessible from QML by importing the URL, "\c{io.qt.examples.backend 1.0}". \li Replace the contents of \c main.qml with the following code: -\quotefile code/backend/main.qml +\snippet code/backend/main.qml main_qml The \c BackEnd instance lets you access the \c userName property, which is updated when the TextField's \c text property changes. diff --git a/src/qml/doc/src/qmlfunctions.qdoc b/src/qml/doc/src/qmlfunctions.qdoc index 834684fe6d..e73f1cb59c 100644 --- a/src/qml/doc/src/qmlfunctions.qdoc +++ b/src/qml/doc/src/qmlfunctions.qdoc @@ -354,7 +354,7 @@ Returns 0 if type \e T is not a valid attaching type, or if \a create is false and no attachment object instance has previously been created for \a attachee. - \sa {Providing Attached Objects for Data Annotations} + \sa {Providing Attached Properties} */ diff --git a/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc b/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc index 33f58dc1b9..0f08cec844 100644 --- a/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc +++ b/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc @@ -50,6 +50,7 @@ The set of QML object-type attribute types is as follows: \li signal handler attributes \li method attributes \li attached properties and attached signal handler attributes +\li enumeration attributes \endlist These attributes are discussed in detail below. @@ -856,8 +857,7 @@ are otherwise unavailable to the object. In particular, they allow objects to access properties or signals that are specifically relevant to the individual object. -A QML type implementation may choose to \l {Providing Attached Objects for -Data Annotations}{create an \e {attaching type} in C++} with +A QML type implementation may choose to \l {Providing Attached Properties}{create an \e {attaching type} in C++} with particular properties and signals. Instances of this type can then be created and \e attached to specific objects at run time, allowing those objects to access the properties and signals of the attaching type. These are accessed by @@ -975,4 +975,41 @@ ListView { Now \c delegateItem.ListView.isCurrentItem correctly refers to the \c isCurrentItem attached property of the delegate. +\section2 Enumeration Attributes + +Enumerations provide a fixed set of named choices. They can be declared in QML using the \c enum keyword: + +\qml +// MyText.qml +Text { + enum TextType { + Normal, + Heading + } +} +\endqml + +As shown above, enumeration types (e.g. \c TextType) and values (e.g. \c Normal) must begin with an uppercase letter. + +Values are referred to via \c {<Type>.<EnumerationType>.<Value>} or \c {<Type>.<Value>}. + +\qml +// MyText.qml +Text { + enum TextType { + Normal, + Heading + } + + property int textType: MyText.TextType.Normal + + font.bold: textType == MyText.TextType.Heading + font.pixelSize: textType == MyText.TextType.Heading ? 24 : 12 +} +\endqml + +More information on enumeration usage in QML can be found in the \l {QML Basic Types} \l enumeration documentation. + +The ability to declare enumerations in QML was introduced in Qt 5.10. + */ |