aboutsummaryrefslogtreecommitdiffstats
path: root/examples/qml
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@digia.com>2013-04-29 15:01:32 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-05-03 23:16:46 +0200
commitad5ae0d751e42a9ca6def5d98b2db740f195c16f (patch)
tree39270a7861f12fb293b621ef51edfa7932a6c2a4 /examples/qml
parentddfa42c85b732972f819a2525293a90539d42d38 (diff)
Doc: Move example docs related to QtQml under the correct module
This change moves 'Extending QML' qdoc file and the tutorials from examples/quick to examples/qml, which is the correct location for them. Change-Id: I24bd9dfa75baaab7bc8efe08489f09a7b65d98a6 Reviewed-by: Jerome Pasion <jerome.pasion@digia.com> Reviewed-by: Sze Howe Koh <szehowe.koh@gmail.com> Reviewed-by: Alan Alpert <aalpert@blackberry.com>
Diffstat (limited to 'examples/qml')
-rw-r--r--examples/qml/doc/src/qml-extending.qdoc322
-rw-r--r--examples/qml/tutorials/extending/chapter1-basics/app.qml60
-rw-r--r--examples/qml/tutorials/extending/chapter1-basics/chapter1-basics.pro5
-rw-r--r--examples/qml/tutorials/extending/chapter1-basics/main.cpp57
-rw-r--r--examples/qml/tutorials/extending/chapter1-basics/piechart.cpp79
-rw-r--r--examples/qml/tutorials/extending/chapter1-basics/piechart.h71
-rw-r--r--examples/qml/tutorials/extending/chapter2-methods/app.qml66
-rw-r--r--examples/qml/tutorials/extending/chapter2-methods/chapter2-methods.pro5
-rw-r--r--examples/qml/tutorials/extending/chapter2-methods/main.cpp57
-rw-r--r--examples/qml/tutorials/extending/chapter2-methods/piechart.cpp84
-rw-r--r--examples/qml/tutorials/extending/chapter2-methods/piechart.h84
-rw-r--r--examples/qml/tutorials/extending/chapter3-bindings/app.qml74
-rw-r--r--examples/qml/tutorials/extending/chapter3-bindings/chapter3-bindings.pro5
-rw-r--r--examples/qml/tutorials/extending/chapter3-bindings/main.cpp57
-rw-r--r--examples/qml/tutorials/extending/chapter3-bindings/piechart.cpp86
-rw-r--r--examples/qml/tutorials/extending/chapter3-bindings/piechart.h84
-rw-r--r--examples/qml/tutorials/extending/chapter4-customPropertyTypes/app.qml60
-rw-r--r--examples/qml/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro7
-rw-r--r--examples/qml/tutorials/extending/chapter4-customPropertyTypes/main.cpp66
-rw-r--r--examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp70
-rw-r--r--examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.h78
-rw-r--r--examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp66
-rw-r--r--examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.h66
-rw-r--r--examples/qml/tutorials/extending/chapter5-listproperties/app.qml70
-rw-r--r--examples/qml/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro7
-rw-r--r--examples/qml/tutorials/extending/chapter5-listproperties/main.cpp58
-rw-r--r--examples/qml/tutorials/extending/chapter5-listproperties/piechart.cpp72
-rw-r--r--examples/qml/tutorials/extending/chapter5-listproperties/piechart.h75
-rw-r--r--examples/qml/tutorials/extending/chapter5-listproperties/pieslice.cpp86
-rw-r--r--examples/qml/tutorials/extending/chapter5-listproperties/pieslice.h76
-rw-r--r--examples/qml/tutorials/extending/chapter6-plugins/Charts/qmldir2
-rw-r--r--examples/qml/tutorials/extending/chapter6-plugins/app.qml69
-rw-r--r--examples/qml/tutorials/extending/chapter6-plugins/chapter6-plugins.pro18
-rw-r--r--examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.cpp53
-rw-r--r--examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.h57
-rw-r--r--examples/qml/tutorials/extending/chapter6-plugins/piechart.cpp70
-rw-r--r--examples/qml/tutorials/extending/chapter6-plugins/piechart.h69
-rw-r--r--examples/qml/tutorials/extending/chapter6-plugins/pieslice.cpp86
-rw-r--r--examples/qml/tutorials/extending/chapter6-plugins/pieslice.h74
-rw-r--r--examples/qml/tutorials/extending/extending.pro10
40 files changed, 2561 insertions, 0 deletions
diff --git a/examples/qml/doc/src/qml-extending.qdoc b/examples/qml/doc/src/qml-extending.qdoc
new file mode 100644
index 0000000000..9823a29b65
--- /dev/null
+++ b/examples/qml/doc/src/qml-extending.qdoc
@@ -0,0 +1,322 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+\example referenceexamples/adding
+\title Extending QML - Adding Types Example
+\brief Exporting C++ Classes
+\ingroup qmlextendingexamples
+
+The Adding Types Example shows how to add a new object type, \c Person, to QML.
+The \c Person type can be used from QML like this:
+
+\snippet referenceexamples/adding/example.qml 0
+
+\section1 Declare the Person class
+
+All QML types map to C++ types. Here we declare a basic C++ Person class
+with the two properties we want accessible on the QML type - name and shoeSize.
+Although in this example we use the same name for the C++ class as the QML
+type, the C++ class can be named differently, or appear in a namespace.
+
+\snippet referenceexamples/adding/person.h 0
+
+\section1 Define the Person class
+
+\snippet referenceexamples/adding/person.cpp 0
+
+The Person class implementation is quite basic. The property accessors simply
+return members of the object instance.
+
+The \c main.cpp file also calls the \c qmlRegisterType() function to
+register the \c Person type with QML as a type in the People library version 1.0,
+and defines the mapping between the C++ and QML class names.
+
+\section1 Running the example
+
+The main.cpp file in the example includes a simple shell application that
+loads and runs the QML snippet shown at the beginning of this page.
+*/
+
+/*!
+\example referenceexamples/properties
+\title Extending QML - Object and List Property Types Example
+\brief Exporting C++ Properties
+\ingroup qmlextendingexamples
+
+This example builds on:
+\list
+\li \l {Extending QML - Adding Types Example}
+\endlist
+
+The Object and List Property Types example shows how to add object and list
+properties in QML. This example adds a BirthdayParty type that specifies
+a birthday party, consisting of a celebrant and a list of guests. People are
+specified using the People QML type built in the previous example.
+
+\snippet referenceexamples/properties/example.qml 0
+
+\section1 Declare the BirthdayParty
+
+The BirthdayParty class is declared like this:
+
+\snippet referenceexamples/properties/birthdayparty.h 0
+\snippet referenceexamples/properties/birthdayparty.h 1
+\snippet referenceexamples/properties/birthdayparty.h 2
+\snippet referenceexamples/properties/birthdayparty.h 3
+
+The class contains a member to store the celebrant object, and also a
+QList<Person *> member.
+
+In QML, the type of a list properties - and the guests property is a list of
+people - are all of type QDeclarativeListProperty<T>. QDeclarativeListProperty is simple value
+type that contains a set of function pointers. QML calls these function
+pointers whenever it needs to read from, write to or otherwise interact with
+the list. In addition to concrete lists like the people list used in this
+example, the use of QDeclarativeListProperty allows for "virtual lists" and other advanced
+scenarios.
+
+\section2 Define the BirthdayParty
+
+The implementation of BirthdayParty property accessors is straight forward.
+
+\snippet referenceexamples/properties/birthdayparty.cpp 0
+
+\section1 Running the example
+
+The main.cpp file in the example includes a simple shell application that
+loads and runs the QML snippet shown at the beginning of this page.
+*/
+
+/*!
+\example referenceexamples/coercion
+\title Extending QML - Inheritance and Coercion Example
+\brief C++ Inheritance and Coercion
+\ingroup qmlextendingexamples
+
+This example builds on:
+\list
+\li \l {Extending QML - Object and List Property Types Example}
+\li \l {Extending QML - Adding Types Example}
+\endlist
+
+The Inheritance and Coercion Example shows how to use base classes to assign
+types of more than one type to a property. It specializes the Person type
+developed in the previous examples into two types - a \c Boy and a \c Girl.
+
+\snippet referenceexamples/coercion/example.qml 0
+
+\section1 Declare Boy and Girl
+
+\snippet referenceexamples/coercion/person.h 0
+
+The Person class remains unaltered in this example and the Boy and Girl C++
+classes are trivial extensions of it. As an example, the inheritance used here
+is a little contrived, but in real applications it is likely that the two
+extensions would add additional properties or modify the Person classes
+behavior.
+
+\section2 Define People as a base class
+
+The implementation of the People class itself has not changed since the
+previous example. However, as we have repurposed the People class as a common
+base for Boy and Girl, we want to prevent it from being instantiated from QML
+directly - an explicit Boy or Girl should be instantiated instead.
+
+\snippet referenceexamples/coercion/main.cpp 0
+
+While we want to disallow instantiating Person from within QML, it still needs
+to be registered with the QML engine, so that it can be used as a property type
+and other types can be coerced to it.
+
+\section2 Define Boy and Girl
+
+The implementation of Boy and Girl are trivial.
+
+\snippet referenceexamples/coercion/person.cpp 1
+
+All that is necessary is to implement the constructor, and to register the types
+and their QML name with the QML engine.
+
+\section1 Running the example
+
+The BirthdayParty type has not changed since the previous example. The
+celebrant and guests property still use the People type.
+
+\snippet referenceexamples/coercion/birthdayparty.h 0
+
+However, as all three types, Person, Boy and Girl, have been registered with the
+QML system, on assignment QML automatically (and type-safely) converts the Boy
+and Girl objects into a Person.
+
+The main.cpp file in the example includes a simple shell application that
+loads and runs the QML snippet shown at the beginning of this page.
+*/
+
+/*!
+\example referenceexamples/default
+\title Extending QML - Default Property Example
+\brief Default Property
+\ingroup qmlextendingexamples
+
+This example builds on:
+\list
+\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 Default Property Example is a minor modification of the
+\l {Extending QML - Inheritance and Coercion Example} that simplifies the
+specification of a BirthdayParty through the use of a default property.
+
+\snippet referenceexamples/default/example.qml 0
+
+\section1 Declaring the BirthdayParty class
+
+The only difference between this example and the last, is the addition of the
+\c DefaultProperty class info annotation.
+
+\snippet referenceexamples/default/birthdayparty.h 0
+
+The default property specifies the property to assign to whenever an explicit
+property is not specified, in the case of the BirthdayParty type the guest
+property. It is purely a syntactic simplification, the behavior is identical
+to specifying the property by name, but it can add a more natural feel in many
+situations. The default property must be either an object or list property.
+
+\section1 Running the example
+
+The main.cpp file in the example includes a simple shell application that
+loads and runs the QML snippet shown at the beginning of this page.
+*/
+
+/*!
+\example referenceexamples/grouped
+\title Extending QML - Grouped Properties Example
+\brief Grouped Properties
+\ingroup qmlextendingexamples
+
+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
+
+*/
+
+/*!
+\example referenceexamples/attached
+\title Extending QML - Attached Properties Example
+\brief Attached Properties
+\ingroup qmlextendingexamples
+
+This example builds on:
+\list
+\li \l {Extending QML - Grouped Properties Example}
+\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
+
+*/
+
+/*!
+\example referenceexamples/signal
+\title Extending QML - Signal Support Example
+\brief Signal Support
+\ingroup qmlextendingexamples
+
+This example builds on:
+\list
+\li \l {Extending QML - Attached Properties Example}
+\li \l {Extending QML - Grouped Properties Example}
+\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
+
+*/
+
+/*!
+\example referenceexamples/methods
+\title Extending QML - Methods Example
+\brief Methods Support
+\ingroup qmlextendingexamples
+
+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
+
+*/
+
+/*!
+\example referenceexamples/valuesource
+\title Extending QML - Property Value Source Example
+\brief Property Value Source
+\ingroup qmlextendingexamples
+
+This example builds on:
+\list
+\li \l {Extending QML - Signal Support Example}
+\li \l {Extending QML - Attached Properties Example}
+\li \l {Extending QML - Grouped Properties Example}
+\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
+
+*/
+
+/*!
+\example referenceexamples/binding
+\title Extending QML - Binding Example
+\brief Binding
+\ingroup qmlextendingexamples
+
+This example builds on:
+\list
+\li \l {Extending QML - Property Value Source Example}
+\li \l {Extending QML - Signal Support Example}
+\li \l {Extending QML - Attached Properties Example}
+\li \l {Extending QML - Grouped Properties Example}
+\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
+
+*/
diff --git a/examples/qml/tutorials/extending/chapter1-basics/app.qml b/examples/qml/tutorials/extending/chapter1-basics/app.qml
new file mode 100644
index 0000000000..d2f03daf83
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter1-basics/app.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+import Charts 1.0
+import QtQuick 2.0
+
+Item {
+ width: 300; height: 200
+
+ PieChart {
+ id: aPieChart
+ anchors.centerIn: parent
+ width: 100; height: 100
+ name: "A simple pie chart"
+ color: "red"
+ }
+
+ Text {
+ anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 }
+ text: aPieChart.name
+ }
+}
+//![0]
diff --git a/examples/qml/tutorials/extending/chapter1-basics/chapter1-basics.pro b/examples/qml/tutorials/extending/chapter1-basics/chapter1-basics.pro
new file mode 100644
index 0000000000..8ed66f8b66
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter1-basics/chapter1-basics.pro
@@ -0,0 +1,5 @@
+QT += qml quick
+
+HEADERS += piechart.h
+SOURCES += piechart.cpp \
+ main.cpp
diff --git a/examples/qml/tutorials/extending/chapter1-basics/main.cpp b/examples/qml/tutorials/extending/chapter1-basics/main.cpp
new file mode 100644
index 0000000000..d30628fd5a
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter1-basics/main.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+#include "piechart.h"
+#include <QtQuick/QQuickView>
+#include <QGuiApplication>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");
+
+ QQuickView view;
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ view.setSource(QUrl::fromLocalFile("app.qml"));
+ view.show();
+ return app.exec();
+}
+//![0]
diff --git a/examples/qml/tutorials/extending/chapter1-basics/piechart.cpp b/examples/qml/tutorials/extending/chapter1-basics/piechart.cpp
new file mode 100644
index 0000000000..fa005781d8
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter1-basics/piechart.cpp
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "piechart.h"
+#include <QPainter>
+
+//![0]
+PieChart::PieChart(QQuickItem *parent)
+ : QQuickPaintedItem(parent)
+{
+}
+//![0]
+
+QString PieChart::name() const
+{
+ return m_name;
+}
+
+void PieChart::setName(const QString &name)
+{
+ m_name = name;
+}
+
+QColor PieChart::color() const
+{
+ return m_color;
+}
+
+void PieChart::setColor(const QColor &color)
+{
+ m_color = color;
+}
+
+//![1]
+void PieChart::paint(QPainter *painter)
+{
+ QPen pen(m_color, 2);
+ painter->setPen(pen);
+ painter->setRenderHints(QPainter::Antialiasing, true);
+ painter->drawPie(boundingRect().adjusted(1, 1, -1, -1), 90 * 16, 290 * 16);
+}
+//![1]
+
diff --git a/examples/qml/tutorials/extending/chapter1-basics/piechart.h b/examples/qml/tutorials/extending/chapter1-basics/piechart.h
new file mode 100644
index 0000000000..a6272453ce
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter1-basics/piechart.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PIECHART_H
+#define PIECHART_H
+
+//![0]
+#include <QtQuick/QQuickPaintedItem>
+#include <QColor>
+
+class PieChart : public QQuickPaintedItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QString name READ name WRITE setName)
+ Q_PROPERTY(QColor color READ color WRITE setColor)
+
+public:
+ PieChart(QQuickItem *parent = 0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+ QColor color() const;
+ void setColor(const QColor &color);
+
+ void paint(QPainter *painter);
+
+private:
+ QString m_name;
+ QColor m_color;
+};
+//![0]
+
+#endif
+
diff --git a/examples/qml/tutorials/extending/chapter2-methods/app.qml b/examples/qml/tutorials/extending/chapter2-methods/app.qml
new file mode 100644
index 0000000000..06ecb3a09d
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter2-methods/app.qml
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+import Charts 1.0
+import QtQuick 2.0
+
+Item {
+ width: 300; height: 200
+
+ PieChart {
+ id: aPieChart
+ anchors.centerIn: parent
+ width: 100; height: 100
+ color: "red"
+
+ onChartCleared: console.log("The chart has been cleared")
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: aPieChart.clearChart()
+ }
+
+ Text {
+ anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 }
+ text: "Click anywhere to clear the chart"
+ }
+}
+//![0]
diff --git a/examples/qml/tutorials/extending/chapter2-methods/chapter2-methods.pro b/examples/qml/tutorials/extending/chapter2-methods/chapter2-methods.pro
new file mode 100644
index 0000000000..8ed66f8b66
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter2-methods/chapter2-methods.pro
@@ -0,0 +1,5 @@
+QT += qml quick
+
+HEADERS += piechart.h
+SOURCES += piechart.cpp \
+ main.cpp
diff --git a/examples/qml/tutorials/extending/chapter2-methods/main.cpp b/examples/qml/tutorials/extending/chapter2-methods/main.cpp
new file mode 100644
index 0000000000..d30628fd5a
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter2-methods/main.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+#include "piechart.h"
+#include <QtQuick/QQuickView>
+#include <QGuiApplication>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");
+
+ QQuickView view;
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ view.setSource(QUrl::fromLocalFile("app.qml"));
+ view.show();
+ return app.exec();
+}
+//![0]
diff --git a/examples/qml/tutorials/extending/chapter2-methods/piechart.cpp b/examples/qml/tutorials/extending/chapter2-methods/piechart.cpp
new file mode 100644
index 0000000000..ddcb1b3efd
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter2-methods/piechart.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "piechart.h"
+#include <QPainter>
+
+PieChart::PieChart(QQuickItem *parent)
+ : QQuickPaintedItem(parent)
+{
+}
+
+QString PieChart::name() const
+{
+ return m_name;
+}
+
+void PieChart::setName(const QString &name)
+{
+ m_name = name;
+}
+
+QColor PieChart::color() const
+{
+ return m_color;
+}
+
+void PieChart::setColor(const QColor &color)
+{
+ m_color = color;
+}
+
+void PieChart::paint(QPainter *painter)
+{
+ QPen pen(m_color, 2);
+ painter->setPen(pen);
+ painter->setRenderHints(QPainter::Antialiasing, true);
+ painter->drawPie(boundingRect().adjusted(1, 1, -1, -1), 90 * 16, 290 * 16);
+}
+
+//![0]
+void PieChart::clearChart()
+{
+ setColor(QColor(Qt::transparent));
+ update();
+
+ emit chartCleared();
+}
+//![0]
diff --git a/examples/qml/tutorials/extending/chapter2-methods/piechart.h b/examples/qml/tutorials/extending/chapter2-methods/piechart.h
new file mode 100644
index 0000000000..86750197d2
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter2-methods/piechart.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PIECHART_H
+#define PIECHART_H
+
+#include <QtQuick/QQuickPaintedItem>
+#include <QColor>
+
+//![0]
+class PieChart : public QQuickPaintedItem
+{
+//![0]
+ Q_OBJECT
+ Q_PROPERTY(QString name READ name WRITE setName)
+ Q_PROPERTY(QColor color READ color WRITE setColor)
+
+//![1]
+public:
+//![1]
+
+ PieChart(QQuickItem *parent = 0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+ QColor color() const;
+ void setColor(const QColor &color);
+
+ void paint(QPainter *painter);
+
+//![2]
+ Q_INVOKABLE void clearChart();
+
+signals:
+ void chartCleared();
+//![2]
+
+private:
+ QString m_name;
+ QColor m_color;
+
+//![3]
+};
+//![3]
+
+#endif
+
diff --git a/examples/qml/tutorials/extending/chapter3-bindings/app.qml b/examples/qml/tutorials/extending/chapter3-bindings/app.qml
new file mode 100644
index 0000000000..afb9e25c51
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter3-bindings/app.qml
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+import Charts 1.0
+import QtQuick 2.0
+
+Item {
+ width: 300; height: 200
+
+ Row {
+ anchors.centerIn: parent
+ spacing: 20
+
+ PieChart {
+ id: chartA
+ width: 100; height: 100
+ color: "red"
+ }
+
+ PieChart {
+ id: chartB
+ width: 100; height: 100
+ color: chartA.color
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { chartA.color = "blue" }
+ }
+
+ Text {
+ anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 }
+ text: "Click anywhere to change the chart color"
+ }
+}
+//![0]
diff --git a/examples/qml/tutorials/extending/chapter3-bindings/chapter3-bindings.pro b/examples/qml/tutorials/extending/chapter3-bindings/chapter3-bindings.pro
new file mode 100644
index 0000000000..8ed66f8b66
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter3-bindings/chapter3-bindings.pro
@@ -0,0 +1,5 @@
+QT += qml quick
+
+HEADERS += piechart.h
+SOURCES += piechart.cpp \
+ main.cpp
diff --git a/examples/qml/tutorials/extending/chapter3-bindings/main.cpp b/examples/qml/tutorials/extending/chapter3-bindings/main.cpp
new file mode 100644
index 0000000000..d30628fd5a
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter3-bindings/main.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+#include "piechart.h"
+#include <QtQuick/QQuickView>
+#include <QGuiApplication>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");
+
+ QQuickView view;
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ view.setSource(QUrl::fromLocalFile("app.qml"));
+ view.show();
+ return app.exec();
+}
+//![0]
diff --git a/examples/qml/tutorials/extending/chapter3-bindings/piechart.cpp b/examples/qml/tutorials/extending/chapter3-bindings/piechart.cpp
new file mode 100644
index 0000000000..a63035033f
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter3-bindings/piechart.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "piechart.h"
+#include <QPainter>
+
+PieChart::PieChart(QQuickItem *parent)
+ : QQuickPaintedItem(parent)
+{
+}
+
+QString PieChart::name() const
+{
+ return m_name;
+}
+
+void PieChart::setName(const QString &name)
+{
+ m_name = name;
+}
+
+QColor PieChart::color() const
+{
+ return m_color;
+}
+
+//![0]
+void PieChart::setColor(const QColor &color)
+{
+ if (color != m_color) {
+ m_color = color;
+ update(); // repaint with the new color
+ emit colorChanged();
+ }
+}
+//![0]
+
+void PieChart::paint(QPainter *painter)
+{
+ QPen pen(m_color, 2);
+ painter->setPen(pen);
+ painter->setRenderHints(QPainter::Antialiasing, true);
+ painter->drawPie(boundingRect().adjusted(1, 1, -1, -1), 90 * 16, 290 * 16);
+}
+
+void PieChart::clearChart()
+{
+ setColor(QColor(Qt::transparent));
+ update();
+}
diff --git a/examples/qml/tutorials/extending/chapter3-bindings/piechart.h b/examples/qml/tutorials/extending/chapter3-bindings/piechart.h
new file mode 100644
index 0000000000..25e82d66cc
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter3-bindings/piechart.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PIECHART_H
+#define PIECHART_H
+
+#include <QColor>
+#include <QtQuick/QQuickPaintedItem>
+
+//![0]
+class PieChart : public QQuickPaintedItem
+{
+//![0]
+ Q_OBJECT
+ Q_PROPERTY(QString name READ name WRITE setName)
+
+//![1]
+ Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
+public:
+//![1]
+
+ PieChart(QQuickItem *parent = 0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+ QColor color() const;
+ void setColor(const QColor &color);
+
+ void paint(QPainter *painter);
+
+ Q_INVOKABLE void clearChart();
+
+//![2]
+signals:
+ void colorChanged();
+//![2]
+
+private:
+ QString m_name;
+ QColor m_color;
+
+//![3]
+};
+//![3]
+
+#endif
+
diff --git a/examples/qml/tutorials/extending/chapter4-customPropertyTypes/app.qml b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/app.qml
new file mode 100644
index 0000000000..441b7f9b82
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/app.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+import Charts 1.0
+import QtQuick 2.0
+
+Item {
+ width: 300; height: 200
+
+ PieChart {
+ id: chart
+ anchors.centerIn: parent
+ width: 100; height: 100
+
+ pieSlice: PieSlice {
+ anchors.fill: parent
+ color: "red"
+ }
+ }
+
+ Component.onCompleted: console.log("The pie is colored " + chart.pieSlice.color)
+}
+//![0]
diff --git a/examples/qml/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro
new file mode 100644
index 0000000000..23eb222ea3
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro
@@ -0,0 +1,7 @@
+QT += qml quick
+
+HEADERS += piechart.h \
+ pieslice.h
+SOURCES += piechart.cpp \
+ pieslice.cpp \
+ main.cpp
diff --git a/examples/qml/tutorials/extending/chapter4-customPropertyTypes/main.cpp b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/main.cpp
new file mode 100644
index 0000000000..5b6e1cf451
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/main.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "piechart.h"
+#include "pieslice.h"
+
+#include <QtQuick/QQuickView>
+#include <QGuiApplication>
+
+//![0]
+int main(int argc, char *argv[])
+{
+//![0]
+ QGuiApplication app(argc, argv);
+
+ qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");
+
+//![1]
+ qmlRegisterType<PieSlice>("Charts", 1, 0, "PieSlice");
+//![1]
+
+ QQuickView view;
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ view.setSource(QUrl::fromLocalFile("app.qml"));
+ view.show();
+ return app.exec();
+
+//![2]
+}
+//![2]
diff --git a/examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp
new file mode 100644
index 0000000000..c1e2996e83
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "piechart.h"
+#include "pieslice.h"
+
+PieChart::PieChart(QQuickItem *parent)
+ : QQuickItem(parent)
+{
+}
+
+QString PieChart::name() const
+{
+ return m_name;
+}
+
+void PieChart::setName(const QString &name)
+{
+ m_name = name;
+}
+
+PieSlice *PieChart::pieSlice() const
+{
+ return m_pieSlice;
+}
+
+//![0]
+void PieChart::setPieSlice(PieSlice *pieSlice)
+{
+ m_pieSlice = pieSlice;
+ pieSlice->setParentItem(this);
+}
+//![0]
+
diff --git a/examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.h b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.h
new file mode 100644
index 0000000000..9f0ea47eb9
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PIECHART_H
+#define PIECHART_H
+
+#include <QtQuick/QQuickItem>
+
+class PieSlice;
+
+//![0]
+class PieChart : public QQuickItem
+{
+ Q_OBJECT
+ Q_PROPERTY(PieSlice* pieSlice READ pieSlice WRITE setPieSlice)
+//![0]
+ Q_PROPERTY(QString name READ name WRITE setName)
+
+//![1]
+public:
+//![1]
+
+ PieChart(QQuickItem *parent = 0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+//![2]
+ PieSlice *pieSlice() const;
+ void setPieSlice(PieSlice *pieSlice);
+//![2]
+
+private:
+ QString m_name;
+ PieSlice *m_pieSlice;
+
+//![3]
+};
+//![3]
+
+#endif
+
diff --git a/examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp
new file mode 100644
index 0000000000..2afe82048f
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "pieslice.h"
+
+#include <QPainter>
+
+PieSlice::PieSlice(QQuickItem *parent)
+ : QQuickPaintedItem(parent)
+{
+}
+
+QColor PieSlice::color() const
+{
+ return m_color;
+}
+
+void PieSlice::setColor(const QColor &color)
+{
+ m_color = color;
+}
+
+void PieSlice::paint(QPainter *painter)
+{
+ QPen pen(m_color, 2);
+ painter->setPen(pen);
+ painter->setRenderHints(QPainter::Antialiasing, true);
+ painter->drawPie(boundingRect().adjusted(1, 1, -1, -1), 90 * 16, 290 * 16);
+}
+
diff --git a/examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.h b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.h
new file mode 100644
index 0000000000..4eef9bb6d1
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PIESLICE_H
+#define PIESLICE_H
+
+#include <QtQuick/QQuickPaintedItem>
+#include <QColor>
+
+//![0]
+class PieSlice : public QQuickPaintedItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QColor color READ color WRITE setColor)
+
+public:
+ PieSlice(QQuickItem *parent = 0);
+
+ QColor color() const;
+ void setColor(const QColor &color);
+
+ void paint(QPainter *painter);
+
+private:
+ QColor m_color;
+};
+//![0]
+
+#endif
+
diff --git a/examples/qml/tutorials/extending/chapter5-listproperties/app.qml b/examples/qml/tutorials/extending/chapter5-listproperties/app.qml
new file mode 100644
index 0000000000..a57d1b833f
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter5-listproperties/app.qml
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+import Charts 1.0
+import QtQuick 2.0
+
+Item {
+ width: 300; height: 200
+
+ PieChart {
+ anchors.centerIn: parent
+ width: 100; height: 100
+
+ slices: [
+ PieSlice {
+ anchors.fill: parent
+ color: "red"
+ fromAngle: 0; angleSpan: 110
+ },
+ PieSlice {
+ anchors.fill: parent
+ color: "black"
+ fromAngle: 110; angleSpan: 50
+ },
+ PieSlice {
+ anchors.fill: parent
+ color: "blue"
+ fromAngle: 160; angleSpan: 100
+ }
+ ]
+ }
+}
+//![0]
diff --git a/examples/qml/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro b/examples/qml/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro
new file mode 100644
index 0000000000..23eb222ea3
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro
@@ -0,0 +1,7 @@
+QT += qml quick
+
+HEADERS += piechart.h \
+ pieslice.h
+SOURCES += piechart.cpp \
+ pieslice.cpp \
+ main.cpp
diff --git a/examples/qml/tutorials/extending/chapter5-listproperties/main.cpp b/examples/qml/tutorials/extending/chapter5-listproperties/main.cpp
new file mode 100644
index 0000000000..f8826f6c31
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter5-listproperties/main.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "piechart.h"
+#include "pieslice.h"
+
+#include <QtQuick/QQuickView>
+#include <QGuiApplication>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");
+ qmlRegisterType<PieSlice>("Charts", 1, 0, "PieSlice");
+
+ QQuickView view;
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ view.setSource(QUrl::fromLocalFile("app.qml"));
+ view.show();
+ return app.exec();
+}
diff --git a/examples/qml/tutorials/extending/chapter5-listproperties/piechart.cpp b/examples/qml/tutorials/extending/chapter5-listproperties/piechart.cpp
new file mode 100644
index 0000000000..9fb61d9cd8
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter5-listproperties/piechart.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "piechart.h"
+#include "pieslice.h"
+
+PieChart::PieChart(QQuickItem *parent)
+ : QQuickItem(parent)
+{
+}
+
+QString PieChart::name() const
+{
+ return m_name;
+}
+
+void PieChart::setName(const QString &name)
+{
+ m_name = name;
+}
+
+//![0]
+QQmlListProperty<PieSlice> PieChart::slices()
+{
+ return QQmlListProperty<PieSlice>(this, 0, &PieChart::append_slice, 0, 0, 0);
+}
+
+void PieChart::append_slice(QQmlListProperty<PieSlice> *list, PieSlice *slice)
+{
+ PieChart *chart = qobject_cast<PieChart *>(list->object);
+ if (chart) {
+ slice->setParentItem(chart);
+ chart->m_slices.append(slice);
+ }
+}
+//![0]
diff --git a/examples/qml/tutorials/extending/chapter5-listproperties/piechart.h b/examples/qml/tutorials/extending/chapter5-listproperties/piechart.h
new file mode 100644
index 0000000000..55488f4900
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter5-listproperties/piechart.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PIECHART_H
+#define PIECHART_H
+
+#include <QtQuick/QQuickItem>
+
+class PieSlice;
+
+//![0]
+class PieChart : public QQuickItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QQmlListProperty<PieSlice> slices READ slices)
+//![0]
+ Q_PROPERTY(QString name READ name WRITE setName)
+
+//![1]
+public:
+//![1]
+ PieChart(QQuickItem *parent = 0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+//![2]
+ QQmlListProperty<PieSlice> slices();
+
+private:
+ static void append_slice(QQmlListProperty<PieSlice> *list, PieSlice *slice);
+
+ QString m_name;
+ QList<PieSlice *> m_slices;
+};
+//![2]
+
+#endif
+
diff --git a/examples/qml/tutorials/extending/chapter5-listproperties/pieslice.cpp b/examples/qml/tutorials/extending/chapter5-listproperties/pieslice.cpp
new file mode 100644
index 0000000000..52b409aa22
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter5-listproperties/pieslice.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "pieslice.h"
+
+#include <QPainter>
+
+PieSlice::PieSlice(QQuickItem *parent)
+ : QQuickPaintedItem(parent)
+{
+}
+
+QColor PieSlice::color() const
+{
+ return m_color;
+}
+
+void PieSlice::setColor(const QColor &color)
+{
+ m_color = color;
+}
+
+int PieSlice::fromAngle() const
+{
+ return m_fromAngle;
+}
+
+void PieSlice::setFromAngle(int angle)
+{
+ m_fromAngle = angle;
+}
+
+int PieSlice::angleSpan() const
+{
+ return m_angleSpan;
+}
+
+void PieSlice::setAngleSpan(int angle)
+{
+ m_angleSpan = angle;
+}
+
+void PieSlice::paint(QPainter *painter)
+{
+ QPen pen(m_color, 2);
+ painter->setPen(pen);
+ painter->setRenderHints(QPainter::Antialiasing, true);
+ painter->drawPie(boundingRect().adjusted(1, 1, -1, -1), m_fromAngle * 16, m_angleSpan * 16);
+}
+
diff --git a/examples/qml/tutorials/extending/chapter5-listproperties/pieslice.h b/examples/qml/tutorials/extending/chapter5-listproperties/pieslice.h
new file mode 100644
index 0000000000..f324179481
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter5-listproperties/pieslice.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PIESLICE_H
+#define PIESLICE_H
+
+#include <QtQuick/QQuickPaintedItem>
+#include <QColor>
+
+//![0]
+class PieSlice : public QQuickPaintedItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QColor color READ color WRITE setColor)
+ Q_PROPERTY(int fromAngle READ fromAngle WRITE setFromAngle)
+ Q_PROPERTY(int angleSpan READ angleSpan WRITE setAngleSpan)
+//![0]
+
+public:
+ PieSlice(QQuickItem *parent = 0);
+
+ QColor color() const;
+ void setColor(const QColor &color);
+
+ int fromAngle() const;
+ void setFromAngle(int angle);
+
+ int angleSpan() const;
+ void setAngleSpan(int span);
+
+ void paint(QPainter *painter);
+
+private:
+ QColor m_color;
+ int m_fromAngle;
+ int m_angleSpan;
+};
+
+#endif
+
diff --git a/examples/qml/tutorials/extending/chapter6-plugins/Charts/qmldir b/examples/qml/tutorials/extending/chapter6-plugins/Charts/qmldir
new file mode 100644
index 0000000000..d9e8471b3c
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter6-plugins/Charts/qmldir
@@ -0,0 +1,2 @@
+module Charts
+plugin chartsplugin
diff --git a/examples/qml/tutorials/extending/chapter6-plugins/app.qml b/examples/qml/tutorials/extending/chapter6-plugins/app.qml
new file mode 100644
index 0000000000..417fc6651a
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter6-plugins/app.qml
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import Charts 1.0
+
+Item {
+ width: 300; height: 200
+
+ PieChart {
+ anchors.centerIn: parent
+ width: 100; height: 100
+
+ slices: [
+ PieSlice {
+ anchors.fill: parent
+ color: "red"
+ fromAngle: 0; angleSpan: 110
+ },
+ PieSlice {
+ anchors.fill: parent
+ color: "black"
+ fromAngle: 110; angleSpan: 50
+ },
+ PieSlice {
+ anchors.fill: parent
+ color: "blue"
+ fromAngle: 160; angleSpan: 100
+ }
+ ]
+ }
+}
+
diff --git a/examples/qml/tutorials/extending/chapter6-plugins/chapter6-plugins.pro b/examples/qml/tutorials/extending/chapter6-plugins/chapter6-plugins.pro
new file mode 100644
index 0000000000..6bf44b4d15
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter6-plugins/chapter6-plugins.pro
@@ -0,0 +1,18 @@
+TEMPLATE = lib
+CONFIG += plugin
+QT += qml quick
+
+DESTDIR = Charts
+TARGET = chartsplugin
+
+OBJECTS_DIR = tmp
+MOC_DIR = tmp
+
+HEADERS += piechart.h \
+ pieslice.h \
+ chartsplugin.h
+
+SOURCES += piechart.cpp \
+ pieslice.cpp \
+ chartsplugin.cpp
+
diff --git a/examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.cpp b/examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.cpp
new file mode 100644
index 0000000000..fea4c1aa85
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "chartsplugin.h"
+//![0]
+#include "piechart.h"
+#include "pieslice.h"
+#include <qqml.h>
+
+void ChartsPlugin::registerTypes(const char *uri)
+{
+ qmlRegisterType<PieChart>(uri, 1, 0, "PieChart");
+ qmlRegisterType<PieSlice>(uri, 1, 0, "PieSlice");
+}
+
+//![0]
+
diff --git a/examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.h b/examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.h
new file mode 100644
index 0000000000..d768306967
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef CHARTSPLUGIN_H
+#define CHARTSPLUGIN_H
+
+//![0]
+#include <QQmlExtensionPlugin>
+
+class ChartsPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
+
+public:
+ void registerTypes(const char *uri);
+};
+//![0]
+
+#endif
+
diff --git a/examples/qml/tutorials/extending/chapter6-plugins/piechart.cpp b/examples/qml/tutorials/extending/chapter6-plugins/piechart.cpp
new file mode 100644
index 0000000000..295bb8961d
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter6-plugins/piechart.cpp
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "piechart.h"
+#include "pieslice.h"
+
+PieChart::PieChart(QQuickItem *parent)
+ : QQuickItem(parent)
+{
+}
+
+QString PieChart::name() const
+{
+ return m_name;
+}
+
+void PieChart::setName(const QString &name)
+{
+ m_name = name;
+}
+
+QQmlListProperty<PieSlice> PieChart::slices()
+{
+ return QQmlListProperty<PieSlice>(this, 0, &PieChart::append_slice, 0, 0, 0);
+}
+
+void PieChart::append_slice(QQmlListProperty<PieSlice> *list, PieSlice *slice)
+{
+ PieChart *chart = qobject_cast<PieChart *>(list->object);
+ if (chart) {
+ slice->setParentItem(chart);
+ chart->m_slices.append(slice);
+ }
+}
diff --git a/examples/qml/tutorials/extending/chapter6-plugins/piechart.h b/examples/qml/tutorials/extending/chapter6-plugins/piechart.h
new file mode 100644
index 0000000000..b37bcdd411
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter6-plugins/piechart.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PIECHART_H
+#define PIECHART_H
+
+#include <QtQuick/QQuickItem>
+
+class PieSlice;
+
+class PieChart : public QQuickItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QQmlListProperty<PieSlice> slices READ slices)
+ Q_PROPERTY(QString name READ name WRITE setName)
+
+public:
+ PieChart(QQuickItem *parent = 0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+ QQmlListProperty<PieSlice> slices();
+
+private:
+ static void append_slice(QQmlListProperty<PieSlice> *list, PieSlice *slice);
+
+ QString m_name;
+ QList<PieSlice *> m_slices;
+};
+
+#endif
+
diff --git a/examples/qml/tutorials/extending/chapter6-plugins/pieslice.cpp b/examples/qml/tutorials/extending/chapter6-plugins/pieslice.cpp
new file mode 100644
index 0000000000..52b409aa22
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter6-plugins/pieslice.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "pieslice.h"
+
+#include <QPainter>
+
+PieSlice::PieSlice(QQuickItem *parent)
+ : QQuickPaintedItem(parent)
+{
+}
+
+QColor PieSlice::color() const
+{
+ return m_color;
+}
+
+void PieSlice::setColor(const QColor &color)
+{
+ m_color = color;
+}
+
+int PieSlice::fromAngle() const
+{
+ return m_fromAngle;
+}
+
+void PieSlice::setFromAngle(int angle)
+{
+ m_fromAngle = angle;
+}
+
+int PieSlice::angleSpan() const
+{
+ return m_angleSpan;
+}
+
+void PieSlice::setAngleSpan(int angle)
+{
+ m_angleSpan = angle;
+}
+
+void PieSlice::paint(QPainter *painter)
+{
+ QPen pen(m_color, 2);
+ painter->setPen(pen);
+ painter->setRenderHints(QPainter::Antialiasing, true);
+ painter->drawPie(boundingRect().adjusted(1, 1, -1, -1), m_fromAngle * 16, m_angleSpan * 16);
+}
+
diff --git a/examples/qml/tutorials/extending/chapter6-plugins/pieslice.h b/examples/qml/tutorials/extending/chapter6-plugins/pieslice.h
new file mode 100644
index 0000000000..0b488b4835
--- /dev/null
+++ b/examples/qml/tutorials/extending/chapter6-plugins/pieslice.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PIESLICE_H
+#define PIESLICE_H
+
+#include <QtQuick/QQuickPaintedItem>
+#include <QColor>
+
+class PieSlice : public QQuickPaintedItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QColor color READ color WRITE setColor)
+ Q_PROPERTY(int fromAngle READ fromAngle WRITE setFromAngle)
+ Q_PROPERTY(int angleSpan READ angleSpan WRITE setAngleSpan)
+
+public:
+ PieSlice(QQuickItem *parent = 0);
+
+ QColor color() const;
+ void setColor(const QColor &color);
+
+ int fromAngle() const;
+ void setFromAngle(int angle);
+
+ int angleSpan() const;
+ void setAngleSpan(int span);
+
+ void paint(QPainter *painter);
+
+private:
+ QColor m_color;
+ int m_fromAngle;
+ int m_angleSpan;
+};
+
+#endif
+
diff --git a/examples/qml/tutorials/extending/extending.pro b/examples/qml/tutorials/extending/extending.pro
new file mode 100644
index 0000000000..967473fda0
--- /dev/null
+++ b/examples/qml/tutorials/extending/extending.pro
@@ -0,0 +1,10 @@
+TEMPLATE = subdirs
+
+SUBDIRS += \
+ chapter1-basics \
+ chapter2-methods \
+ chapter3-bindings \
+ chapter4-customPropertyTypes \
+ chapter5-listproperties \
+ chapter6-plugins
+