aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-01-14 21:52:09 +0100
committerLiang Qi <liang.qi@qt.io>2017-01-14 22:17:32 +0100
commit60300fda463ae0f31c1e66ca253a2a976a88ee20 (patch)
treeb2264433418280ccbb7ed173892456fce4fab43a /examples
parentdb462cce86dba0be80239d4aaaea668ef173af3d (diff)
parent0e3380f9c6ab6e3ea7398caccf5aa84f1575f1cd (diff)
Merge remote-tracking branch 'origin/5.8' into dev
Conflicts: .qmake.conf Change-Id: I9d87ed86e95b5901a86cc3aa65d7ac39b0b708c2
Diffstat (limited to 'examples')
-rw-r--r--examples/qml/doc/src/qml-extending.qdoc28
-rw-r--r--examples/qml/referenceexamples/extended/main.cpp4
-rw-r--r--examples/qml/referenceexamples/methods/example.qml4
-rw-r--r--examples/quick/scenegraph/graph/graph.cpp2
4 files changed, 31 insertions, 7 deletions
diff --git a/examples/qml/doc/src/qml-extending.qdoc b/examples/qml/doc/src/qml-extending.qdoc
index 0812a3dba1..b4174426a8 100644
--- a/examples/qml/doc/src/qml-extending.qdoc
+++ b/examples/qml/doc/src/qml-extending.qdoc
@@ -75,9 +75,21 @@ This example builds on:
Shows how to use \l {QQmlEngine::}{qmlRegisterExtendedType()} to provide an \l {Registering
Extension Objects}{extension object} to a \l QLineEdit without modifying or
-subclassing. The QML engine instantiates a \l QLineEdit and sets a property that
-only exists on the extension type. The extension type performs calls on the \l
-QLineEdit that otherwise will not be accessible to the QML engine.
+subclassing.
+
+\snippet referenceexamples/extended/main.cpp 0
+
+The QML engine instantiates a \l QLineEdit
+
+\snippet referenceexamples/extended/main.cpp 1
+
+and sets a property that oly exists on the extension type.
+
+\snippet referenceexamples/extended/example.qml 0
+
+The QML engine instantiates a \l QLineEdit and sets a property that
+only exists on the extension type. The extension type performs calls on the
+\l QLineEdit that otherwise will not be accessible to the QML engine.
*/
@@ -293,12 +305,20 @@ This example builds on:
This example builds on:
\list
-\li \l {Extending QML - Default Property Example}
\li \l {Extending QML - Inheritance and Coercion Example}
\li \l {Extending QML - Object and List Property Types Example}
\li \l {Extending QML - Adding Types Example}
\endlist
+The Methods Example has an additional method in the \c BirthdayParty class: \c invite().
+\c invite() is declared with \l Q_INVOKABLE so that it can be
+called from QML.
+
+\snippet referenceexamples/methods/birthdayparty.h 0
+
+In \c example.qml, the \c invite() method is called in the \l [QML]{QtQml::Component::completed()}{Component.onCompleted} signal handler:
+
+\snippet referenceexamples/methods/example.qml 0
*/
/*!
diff --git a/examples/qml/referenceexamples/extended/main.cpp b/examples/qml/referenceexamples/extended/main.cpp
index fc11587841..f72cb0d9e2 100644
--- a/examples/qml/referenceexamples/extended/main.cpp
+++ b/examples/qml/referenceexamples/extended/main.cpp
@@ -48,11 +48,15 @@ int main(int argc, char ** argv)
{
QApplication app(argc, argv);
+// ![0]
qmlRegisterExtendedType<QLineEdit, LineEditExtension>("People", 1,0, "QLineEdit");
+// ![0]
+// ![1]
QQmlEngine engine;
QQmlComponent component(&engine, QUrl("qrc:example.qml"));
QLineEdit *edit = qobject_cast<QLineEdit *>(component.create());
+// ![1]
if (edit) {
edit->show();
diff --git a/examples/qml/referenceexamples/methods/example.qml b/examples/qml/referenceexamples/methods/example.qml
index 58985c5d5f..197e6007e1 100644
--- a/examples/qml/referenceexamples/methods/example.qml
+++ b/examples/qml/referenceexamples/methods/example.qml
@@ -38,6 +38,7 @@
**
****************************************************************************/
+// ![0]
import QtQuick 2.0
import People 1.0
@@ -52,7 +53,6 @@ BirthdayParty {
Person { name: "Anne Brown" }
]
-// ![0]
Component.onCompleted: invite("William Green")
-// ![0]
}
+// ![0]
diff --git a/examples/quick/scenegraph/graph/graph.cpp b/examples/quick/scenegraph/graph/graph.cpp
index 389bd384c2..6048a1032c 100644
--- a/examples/quick/scenegraph/graph/graph.cpp
+++ b/examples/quick/scenegraph/graph/graph.cpp
@@ -102,7 +102,7 @@ QSGNode *Graph::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
n->background = new NoisyNode(window());
n->grid = new GridNode();
n->line = new LineNode(10, 0.5, QColor("steelblue"));
- n->shadow = new LineNode(20, 0.2, QColor::fromRgbF(0.2, 0.2, 0.2, 0.4));
+ n->shadow = new LineNode(20, 0.2f, QColor::fromRgbF(0.2, 0.2, 0.2, 0.4));
n->appendChildNode(n->background);
n->appendChildNode(n->grid);