aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/doc
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/doc')
-rw-r--r--src/qml/doc/snippets/code/backend/backend.cpp3
-rw-r--r--src/qml/doc/snippets/code/backend/backend.h3
-rw-r--r--src/qml/doc/snippets/code/backend/main.cpp3
-rw-r--r--src/qml/doc/snippets/code/backend/main.qml4
-rw-r--r--src/qml/doc/snippets/code/src_script_qjsengine.cpp13
-rw-r--r--src/qml/doc/src/cppintegration/data.qdoc2
-rw-r--r--src/qml/doc/src/cppintegration/definetypes.qdoc4
-rw-r--r--src/qml/doc/src/cppintegration/exposecppattributes.qdoc1
-rw-r--r--src/qml/doc/src/cppintegration/topic.qdoc8
-rw-r--r--src/qml/doc/src/qmlfunctions.qdoc2
-rw-r--r--src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc41
11 files changed, 69 insertions, 15 deletions
diff --git a/src/qml/doc/snippets/code/backend/backend.cpp b/src/qml/doc/snippets/code/backend/backend.cpp
index 4a7ee89cec..58f5a15e2a 100644
--- a/src/qml/doc/snippets/code/backend/backend.cpp
+++ b/src/qml/doc/snippets/code/backend/backend.cpp
@@ -47,7 +47,7 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-
+//! [backend_cpp]
#include "backend.h"
BackEnd::BackEnd(QObject *parent) :
@@ -68,3 +68,4 @@ void BackEnd::setUserName(const QString &userName)
m_userName = userName;
emit userNameChanged();
}
+//! [backend_cpp]
diff --git a/src/qml/doc/snippets/code/backend/backend.h b/src/qml/doc/snippets/code/backend/backend.h
index 91bb766e1f..fa7ce9eb86 100644
--- a/src/qml/doc/snippets/code/backend/backend.h
+++ b/src/qml/doc/snippets/code/backend/backend.h
@@ -47,7 +47,7 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-
+//! [backend_header]
#ifndef BACKEND_H
#define BACKEND_H
@@ -73,3 +73,4 @@ private:
};
#endif // BACKEND_H
+//! [backend_header]
diff --git a/src/qml/doc/snippets/code/backend/main.cpp b/src/qml/doc/snippets/code/backend/main.cpp
index d7a1bcbd4f..91a012dfda 100644
--- a/src/qml/doc/snippets/code/backend/main.cpp
+++ b/src/qml/doc/snippets/code/backend/main.cpp
@@ -47,7 +47,7 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-
+//! [main_cpp]
#include <QGuiApplication>
#include <QQmlApplicationEngine>
@@ -64,3 +64,4 @@ int main(int argc, char *argv[])
return app.exec();
}
+//! [main_cpp]
diff --git a/src/qml/doc/snippets/code/backend/main.qml b/src/qml/doc/snippets/code/backend/main.qml
index 3720da8412..fadc9cd768 100644
--- a/src/qml/doc/snippets/code/backend/main.qml
+++ b/src/qml/doc/snippets/code/backend/main.qml
@@ -47,7 +47,7 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-
+//! [main_qml]
import QtQuick 2.6
import QtQuick.Controls 2.0
//![import]
@@ -76,4 +76,4 @@ ApplicationWindow {
}
//![username_input]
}
-
+//! [main_qml]
diff --git a/src/qml/doc/snippets/code/src_script_qjsengine.cpp b/src/qml/doc/snippets/code/src_script_qjsengine.cpp
index c9bd7dfcd9..0305574d34 100644
--- a/src/qml/doc/snippets/code/src_script_qjsengine.cpp
+++ b/src/qml/doc/snippets/code/src_script_qjsengine.cpp
@@ -91,3 +91,16 @@ myEngine.evaluate("button.checkable = true");
qDebug() << scriptButton.property("checkable").toBool();
scriptButton.property("show").call(); // call the show() slot
//! [5]
+
+
+//! [6]
+QJSEngine engine;
+
+QObject *myQObject = new QObject();
+myQObject->setProperty("dynamicProperty", 3);
+
+QJSValue myScriptQObject = engine.newQObject(myQObject);
+engine.globalObject().setProperty("myObject", myScriptQObject);
+
+qDebug() << engine.evaluate("myObject.dynamicProperty").toInt();
+//! [6]
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.
+
*/