diff options
Diffstat (limited to 'doc/src/declarative/extending-tutorial.qdoc')
-rw-r--r-- | doc/src/declarative/extending-tutorial.qdoc | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/doc/src/declarative/extending-tutorial.qdoc b/doc/src/declarative/extending-tutorial.qdoc index 3b2fe3b4d4..dff1d9caa2 100644 --- a/doc/src/declarative/extending-tutorial.qdoc +++ b/doc/src/declarative/extending-tutorial.qdoc @@ -29,7 +29,7 @@ \page qml-extending-tutorial-index.html \title Tutorial: Writing QML extensions with C++ -The QtDeclarative module provides a set of APIs for extending QML through +The Qt Declarative module provides a set of APIs for extending QML through C++ extensions. You can write extensions to add your own QML types, extend existing Qt types, or call C/C++ functions that are not accessible from ordinary QML code. @@ -65,7 +65,7 @@ For example, this could be done to implement particular data models, or provide elements with custom painting and drawing capabilities, or access system features like network programming that are not accessible through built-in QML features. -In this tutorial, we will show how to use the C++ classes in the QtDeclarative +In this tutorial, we will show how to use the C++ classes in the Qt Declarative module to extend QML. The end result will be a simple Pie Chart display implemented by several custom QML types connected together through QML features like bindings and signals, and made available to the QML runtime through a plugin. @@ -260,32 +260,28 @@ custom QML types may see unexpected behavior if bindings are not implemented. The \c PieChart type currently has a string-type property and a color-type property. It could have many other types of properties. For example, it could have an -enum-type property to store a display mode for each chart: +int-type property to store an identifier for each chart: \code // C++ class PieChart : public QDeclarativeItem { - Q_ENUMS(DisplayMode) - Q_PROPERTY(DisplayMode displayMode READ displayMode WRITE setDisplayMode) + Q_PROPERTY(int chartId READ chartId WRITE setChartId NOTIFY chartIdChanged) ... public: - enum DisplayMode { - MultiLevel, - Exploded, - ThreeDimensional - }; - - void setDisplayMode(DisplayMode mode); - DisplayMode displayMode() const; + void setChartId(int chartId); + int chartId() const; ... + + signals: + void chartIdChanged(); }; // QML PieChart { ... - displayMode: PieChart.Exploded + chartId: 100 } \endcode |