diff options
author | Matthew Vogt <matthew.vogt@nokia.com> | 2012-02-16 14:43:03 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-24 04:51:31 +0100 |
commit | b855240b782395f94315f43ea3e7e182299fac48 (patch) | |
tree | bc594c04449be8cd14cd0ab0bb72dafc2be0ffb2 /doc/src/qml/extending-tutorial.qdoc | |
parent | 6a42a6e0a9a1abdda0d07a5a20b4ac7e45348684 (diff) |
Rename QDeclarative symbols to QQuick and QQml
Symbols beginning with QDeclarative are already exported
by the quick1 module.
Users can apply the bin/rename-qtdeclarative-symbols.sh
script to modify client code using the previous names of the
renamed symbols.
Task-number: QTBUG-23737
Change-Id: Ifaa482663767634931e8711a8e9bf6e404859e66
Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'doc/src/qml/extending-tutorial.qdoc')
-rw-r--r-- | doc/src/qml/extending-tutorial.qdoc | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/doc/src/qml/extending-tutorial.qdoc b/doc/src/qml/extending-tutorial.qdoc index 00f4bb5691..b995c32cca 100644 --- a/doc/src/qml/extending-tutorial.qdoc +++ b/doc/src/qml/extending-tutorial.qdoc @@ -100,14 +100,14 @@ Here is our \c PieChart class, defined in \c piechart.h: \snippet declarative/tutorials/extending/chapter1-basics/piechart.h 0 -The class inherits from QDeclarativeItem because we want to override -QDeclarativeItem::paint() in order to draw. If the class just represented some +The class inherits from QQuickItem because we want to override +QQuickItem::paint() in order to draw. If the class just represented some data type and was not an item that actually needed to be displayed, it could simply inherit from QObject. Or, if we want to extend the functionality of an existing QObject-based class, it could inherit from that class instead. The \c PieChart class defines the two properties, \c name and \c color, with the Q_PROPERTY macro, -and overrides QDeclarativeItem::paint(). The class implementation in \c piechart.cpp +and overrides QQuickItem::paint(). The class implementation in \c piechart.cpp simply sets and returns the \c m_name and \c m_color values as appropriate, and implements \c paint() to draw a simple pie chart. It also turns off the QGraphicsItem::ItemHasNoContents flag to enable painting: @@ -127,7 +127,7 @@ converted to a QColor object for the PieChart \c color property. Automatic conve provided for various other \l {QML Basic Types}{basic types}; for example, a string like "640x480" can be automatically converted to a QSize value. -We'll also create a C++ application that uses a QDeclarativeView to run and +We'll also create a C++ application that uses a QQuickView to run and display \c app.qml. The application must register the \c PieChart type using the qmlRegisterType() function, to allow it to be used from QML. If you don't register the type, \c app.qml won't be able to create a \c PieChart. @@ -265,7 +265,7 @@ int-type property to store an identifier for each chart: \code // C++ - class PieChart : public QDeclarativeItem + class PieChart : public QQuickItem { Q_PROPERTY(int chartId READ chartId WRITE setChartId NOTIFY chartIdChanged) ... @@ -306,7 +306,7 @@ we assign an \c PieSlice value which itself contains a \c color: \snippet declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml 0 -Like \c PieChart, this new \c PieSlice type inherits from QDeclarativeItem and declares +Like \c PieChart, this new \c PieSlice type inherits from QQuickItem and declares its properties with Q_PROPERTY(): \snippet declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.h 0 @@ -324,7 +324,7 @@ and associated method signatures: There is one thing to be aware of when implementing \c setPieSlice(). The \c PieSlice is a visual item, so it must be set as a child of the \c PieChart using -QDeclarativeItem::setParentItem() so that the \c PieChart knows to paint this child +QQuickItem::setParentItem() so that the \c PieChart knows to paint this child item when its contents are drawn: \snippet declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp 0 @@ -359,7 +359,7 @@ have a \c slices property that accepts a list of \c PieSlice items: \image extending-tutorial-chapter5.png To do this, we replace the \c pieSlice property in \c PieChart with a \c slices property, -declared as a QDeclarativeListProperty type. The QDeclarativeListProperty class enables the +declared as a QQmlListProperty type. The QQmlListProperty class enables the creation of list properties in QML extensions. We replace the \c pieSlice() function with a \c slices() function that returns a list of slices, and add an internal \c append_slice() function (discussed below). We also use a QList to @@ -372,9 +372,9 @@ store the internal list of slices as \c m_slices: \snippet declarative/tutorials/extending/chapter5-listproperties/piechart.h 2 Although the \c slices property does not have an associated \c WRITE function, -it is still modifiable because of the way QDeclarativeListProperty works. +it is still modifiable because of the way QQmlListProperty works. In the \c PieChart implementation, we implement \c PieChart::slices() to -return a QDeclarativeListProperty value and indicate that the internal +return a QQmlListProperty value and indicate that the internal \c PieChart::append_slice() function is to be called whenever a request is made from QML to add items to the list: @@ -382,7 +382,7 @@ to add items to the list: The \c append_slice() function simply sets the parent item as before, and adds the new item to the \c m_slices list. As you can see, the append function for a -QDeclarativeListProperty is called with two arguments: the list property, and +QQmlListProperty is called with two arguments: the list property, and the item that is to be appended. The \c PieSlice class has also been modified to include \c fromAngle and \c angleSpan @@ -400,7 +400,7 @@ The complete code can be seen in the updated \c examples/tutorials/extending/cha \example declarative/tutorials/extending/chapter6-plugins Currently the \c PieChart and \c PieSlice types are used by \c app.qml, -which is displayed using a QDeclarativeView in a C++ application. An alternative +which is displayed using a QQuickView in a C++ application. An alternative way to use our QML extension is to create a plugin library to make it available to the QML engine. This allows \c app.qml to be loaded with the \l {QML Viewer} (or some other QML \l{Qt Declarative UI Runtime}{runtime} application) instead of writing a \c main.cpp file and @@ -414,8 +414,8 @@ To create a plugin library, we need: \o A \l{Writing a qmldir file}{qmldir} file that tells the QML engine to load the plugin \endlist -First, we create a plugin class named \c ChartsPlugin. It subclasses QDeclarativeExtensionPlugin -and registers our QML types in the inherited \l{QDeclarativeExtensionPlugin::}{registerTypes()} method. It also calls +First, we create a plugin class named \c ChartsPlugin. It subclasses QQmlExtensionPlugin +and registers our QML types in the inherited \l{QQmlExtensionPlugin::}{registerTypes()} method. It also calls Q_EXPORT_PLUGIN2 for Qt's \l{How to Create Qt Plugins}{plugin system}. Here is the \c ChartsPlugin definition in \c chartsplugin.h: @@ -464,7 +464,7 @@ In this tutorial, we've shown the basic steps for creating a QML extension: \o Add callable methods using Q_INVOKABLE or Qt slots, and connect to Qt signals with an \c onSignal syntax \o Add property bindings by defining \l{Qt's Property System}{NOTIFY} signals \o Define custom property types if the built-in types are not sufficient -\o Define list property types using QDeclarativeListProperty +\o Define list property types using QQmlListProperty \o Create a plugin library by defining a Qt plugin and writing a \c qmldir file \endlist |