summaryrefslogtreecommitdiffstats
path: root/examples/declarative
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-04-23 06:42:16 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-04-23 07:18:58 (GMT)
commit3a5040ebacb177e883e2f79660194c1034fa79c2 (patch)
treecc0a943b7758052d6d2959f55b19adf8c046d32c /examples/declarative
parent80d1bc3da3ac03deb321a307a87df1f5f331e48f (diff)
downloadQt-3a5040ebacb177e883e2f79660194c1034fa79c2.zip
Qt-3a5040ebacb177e883e2f79660194c1034fa79c2.tar.gz
Qt-3a5040ebacb177e883e2f79660194c1034fa79c2.tar.bz2
Add tutorial for writing QML extensions
Diffstat (limited to 'examples/declarative')
-rw-r--r--examples/declarative/tutorials/extending/chapter1-basics/app.qml17
-rw-r--r--examples/declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro5
-rw-r--r--examples/declarative/tutorials/extending/chapter1-basics/main.cpp58
-rw-r--r--examples/declarative/tutorials/extending/chapter1-basics/musician.cpp67
-rw-r--r--examples/declarative/tutorials/extending/chapter1-basics/musician.h69
-rw-r--r--examples/declarative/tutorials/extending/chapter2-methods/app.qml19
-rw-r--r--examples/declarative/tutorials/extending/chapter2-methods/chapter2-methods.pro5
-rw-r--r--examples/declarative/tutorials/extending/chapter2-methods/main.cpp58
-rw-r--r--examples/declarative/tutorials/extending/chapter2-methods/musician.cpp75
-rw-r--r--examples/declarative/tutorials/extending/chapter2-methods/musician.h82
-rw-r--r--examples/declarative/tutorials/extending/chapter3-bindings/app.qml31
-rw-r--r--examples/declarative/tutorials/extending/chapter3-bindings/chapter3-bindings.pro5
-rw-r--r--examples/declarative/tutorials/extending/chapter3-bindings/main.cpp58
-rw-r--r--examples/declarative/tutorials/extending/chapter3-bindings/musician.cpp77
-rw-r--r--examples/declarative/tutorials/extending/chapter3-bindings/musician.h83
-rw-r--r--examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml13
-rw-r--r--examples/declarative/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro7
-rw-r--r--examples/declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.cpp57
-rw-r--r--examples/declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.h64
-rw-r--r--examples/declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp67
-rw-r--r--examples/declarative/tutorials/extending/chapter4-customPropertyTypes/musician.cpp68
-rw-r--r--examples/declarative/tutorials/extending/chapter4-customPropertyTypes/musician.h79
-rw-r--r--examples/declarative/tutorials/extending/chapter5-plugins/app.qml13
-rw-r--r--examples/declarative/tutorials/extending/chapter5-plugins/chapter5-plugins.pro15
-rw-r--r--examples/declarative/tutorials/extending/chapter5-plugins/instrument.cpp57
-rw-r--r--examples/declarative/tutorials/extending/chapter5-plugins/instrument.h62
-rw-r--r--examples/declarative/tutorials/extending/chapter5-plugins/musician.cpp68
-rw-r--r--examples/declarative/tutorials/extending/chapter5-plugins/musician.h69
-rw-r--r--examples/declarative/tutorials/extending/chapter5-plugins/musicplugin.cpp55
-rw-r--r--examples/declarative/tutorials/extending/chapter5-plugins/musicplugin.h56
-rw-r--r--examples/declarative/tutorials/extending/chapter5-plugins/qmldir1
31 files changed, 1460 insertions, 0 deletions
diff --git a/examples/declarative/tutorials/extending/chapter1-basics/app.qml b/examples/declarative/tutorials/extending/chapter1-basics/app.qml
new file mode 100644
index 0000000..15dcd2d
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter1-basics/app.qml
@@ -0,0 +1,17 @@
+import Music 1.0
+import Qt 4.7
+
+Rectangle {
+ width: 300; height: 200
+
+ Musician {
+ id: aMusician
+ name: "Reddy the Rocker"
+ instrument: "Guitar"
+ }
+
+ Text {
+ anchors.fill: parent
+ text: aMusician.name + " plays the " + aMusician.instrument
+ }
+}
diff --git a/examples/declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro b/examples/declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro
new file mode 100644
index 0000000..bd05ebe
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro
@@ -0,0 +1,5 @@
+QT += declarative
+
+HEADERS += musician.h
+SOURCES += musician.cpp \
+ main.cpp
diff --git a/examples/declarative/tutorials/extending/chapter1-basics/main.cpp b/examples/declarative/tutorials/extending/chapter1-basics/main.cpp
new file mode 100644
index 0000000..0e71bb0
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter1-basics/main.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+#include "musician.h"
+#include <qdeclarative.h>
+#include <QDeclarativeView>
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ qmlRegisterType<Musician>("Music", 1, 0, "Musician");
+
+ QDeclarativeView view;
+ view.setSource(QUrl::fromLocalFile("app.qml"));
+ view.show();
+ return app.exec();
+}
+//![0]
diff --git a/examples/declarative/tutorials/extending/chapter1-basics/musician.cpp b/examples/declarative/tutorials/extending/chapter1-basics/musician.cpp
new file mode 100644
index 0000000..b545f84
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter1-basics/musician.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "musician.h"
+
+Musician::Musician(QObject *parent)
+ : QObject(parent)
+{
+}
+
+QString Musician::name() const
+{
+ return m_name;
+}
+
+void Musician::setName(const QString &name)
+{
+ m_name = name;
+}
+
+QString Musician::instrument() const
+{
+ return m_instrument;
+}
+
+void Musician::setInstrument(const QString &instrument)
+{
+ m_instrument = instrument;
+}
+
diff --git a/examples/declarative/tutorials/extending/chapter1-basics/musician.h b/examples/declarative/tutorials/extending/chapter1-basics/musician.h
new file mode 100644
index 0000000..70ade82
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter1-basics/musician.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef MUSICIAN_H
+#define MUSICIAN_H
+
+//![0]
+#include <QObject>
+
+class Musician : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QString name READ name WRITE setName)
+ Q_PROPERTY(QString instrument READ instrument WRITE setInstrument)
+
+public:
+ Musician(QObject *parent = 0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+ QString instrument() const;
+ void setInstrument(const QString &instrument);
+
+private:
+ QString m_name;
+ QString m_instrument;
+};
+//![0]
+
+#endif
+
diff --git a/examples/declarative/tutorials/extending/chapter2-methods/app.qml b/examples/declarative/tutorials/extending/chapter2-methods/app.qml
new file mode 100644
index 0000000..35e083e
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter2-methods/app.qml
@@ -0,0 +1,19 @@
+import Music 1.0
+import Qt 4.7
+
+Rectangle {
+ width: 200; height: 200
+
+ Musician {
+ id: aMusician
+ name: "Reddy the Rocker"
+ instrument: "Guitar"
+
+ onPerformanceEnded: console.log("The performance has now ended")
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: aMusician.perform()
+ }
+}
diff --git a/examples/declarative/tutorials/extending/chapter2-methods/chapter2-methods.pro b/examples/declarative/tutorials/extending/chapter2-methods/chapter2-methods.pro
new file mode 100644
index 0000000..bd05ebe
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter2-methods/chapter2-methods.pro
@@ -0,0 +1,5 @@
+QT += declarative
+
+HEADERS += musician.h
+SOURCES += musician.cpp \
+ main.cpp
diff --git a/examples/declarative/tutorials/extending/chapter2-methods/main.cpp b/examples/declarative/tutorials/extending/chapter2-methods/main.cpp
new file mode 100644
index 0000000..0e71bb0
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter2-methods/main.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+#include "musician.h"
+#include <qdeclarative.h>
+#include <QDeclarativeView>
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ qmlRegisterType<Musician>("Music", 1, 0, "Musician");
+
+ QDeclarativeView view;
+ view.setSource(QUrl::fromLocalFile("app.qml"));
+ view.show();
+ return app.exec();
+}
+//![0]
diff --git a/examples/declarative/tutorials/extending/chapter2-methods/musician.cpp b/examples/declarative/tutorials/extending/chapter2-methods/musician.cpp
new file mode 100644
index 0000000..3df19e3
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter2-methods/musician.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "musician.h"
+#include <QDebug>
+
+Musician::Musician(QObject *parent)
+ : QObject(parent)
+{
+}
+
+QString Musician::name() const
+{
+ return m_name;
+}
+
+void Musician::setName(const QString &name)
+{
+ m_name = name;
+}
+
+QString Musician::instrument() const
+{
+ return m_instrument;
+}
+
+void Musician::setInstrument(const QString &instrument)
+{
+ m_instrument = instrument;
+}
+
+//![0]
+void Musician::perform()
+{
+ qWarning() << m_name << "is playing the" << m_instrument;
+ emit performanceEnded();
+}
+//![0]
diff --git a/examples/declarative/tutorials/extending/chapter2-methods/musician.h b/examples/declarative/tutorials/extending/chapter2-methods/musician.h
new file mode 100644
index 0000000..dc48759
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter2-methods/musician.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef MUSICIAN_H
+#define MUSICIAN_H
+
+#include <QObject>
+
+//![0]
+class Musician : public QObject
+{
+//![0]
+ Q_OBJECT
+ Q_PROPERTY(QString name READ name WRITE setName)
+ Q_PROPERTY(QString instrument READ instrument WRITE setInstrument)
+
+//![1]
+public:
+//![1]
+
+ Musician(QObject *parent = 0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+ QString instrument() const;
+ void setInstrument(const QString &instrument);
+
+//![2]
+ Q_INVOKABLE void perform();
+
+signals:
+ void performanceEnded();
+//![2]
+
+private:
+ QString m_name;
+ QString m_instrument;
+
+//![3]
+};
+//![3]
+
+#endif
+
diff --git a/examples/declarative/tutorials/extending/chapter3-bindings/app.qml b/examples/declarative/tutorials/extending/chapter3-bindings/app.qml
new file mode 100644
index 0000000..0460b0b
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter3-bindings/app.qml
@@ -0,0 +1,31 @@
+import Music 1.0
+import Qt 4.7
+
+Rectangle {
+ width: 200; height: 200
+
+ Musician {
+ id: reddy
+ name: "Reddy the Rocker"
+ instrument: "Guitar"
+ }
+
+ Musician {
+ id: craig
+ name: "Craig the Copycat"
+ instrument: reddy.instrument
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ reddy.perform()
+ craig.perform()
+
+ reddy.instrument = "Drums"
+
+ reddy.perform()
+ craig.perform()
+ }
+ }
+}
diff --git a/examples/declarative/tutorials/extending/chapter3-bindings/chapter3-bindings.pro b/examples/declarative/tutorials/extending/chapter3-bindings/chapter3-bindings.pro
new file mode 100644
index 0000000..bd05ebe
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter3-bindings/chapter3-bindings.pro
@@ -0,0 +1,5 @@
+QT += declarative
+
+HEADERS += musician.h
+SOURCES += musician.cpp \
+ main.cpp
diff --git a/examples/declarative/tutorials/extending/chapter3-bindings/main.cpp b/examples/declarative/tutorials/extending/chapter3-bindings/main.cpp
new file mode 100644
index 0000000..0e71bb0
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter3-bindings/main.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+#include "musician.h"
+#include <qdeclarative.h>
+#include <QDeclarativeView>
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ qmlRegisterType<Musician>("Music", 1, 0, "Musician");
+
+ QDeclarativeView view;
+ view.setSource(QUrl::fromLocalFile("app.qml"));
+ view.show();
+ return app.exec();
+}
+//![0]
diff --git a/examples/declarative/tutorials/extending/chapter3-bindings/musician.cpp b/examples/declarative/tutorials/extending/chapter3-bindings/musician.cpp
new file mode 100644
index 0000000..eb615f6
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter3-bindings/musician.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "musician.h"
+#include <QDebug>
+
+Musician::Musician(QObject *parent)
+ : QObject(parent)
+{
+}
+
+QString Musician::name() const
+{
+ return m_name;
+}
+
+void Musician::setName(const QString &name)
+{
+ m_name = name;
+}
+
+QString Musician::instrument() const
+{
+ return m_instrument;
+}
+
+//![0]
+void Musician::setInstrument(const QString &instrument)
+{
+ if (instrument != m_instrument) {
+ m_instrument = instrument;
+ emit instrumentChanged();
+ }
+}
+//![0]
+
+void Musician::perform()
+{
+ qWarning() << m_name << "is playing the" << m_instrument;
+}
diff --git a/examples/declarative/tutorials/extending/chapter3-bindings/musician.h b/examples/declarative/tutorials/extending/chapter3-bindings/musician.h
new file mode 100644
index 0000000..39887be
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter3-bindings/musician.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef MUSICIAN_H
+#define MUSICIAN_H
+
+#include <QObject>
+
+//![0]
+class Musician : public QObject
+{
+//![0]
+ Q_OBJECT
+ Q_PROPERTY(QString name READ name WRITE setName)
+ Q_PROPERTY(QString instrument READ instrument WRITE setInstrument)
+
+//![1]
+ Q_PROPERTY(QString instrument READ instrument WRITE setInstrument NOTIFY instrumentChanged)
+public:
+//![1]
+
+ Musician(QObject *parent = 0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+ QString instrument() const;
+ void setInstrument(const QString &instrument);
+
+ Q_INVOKABLE void perform();
+
+//![2]
+signals:
+ void instrumentChanged();
+//![2]
+
+private:
+ QString m_name;
+ QString m_instrument;
+
+//![3]
+};
+//![3]
+
+#endif
+
diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml
new file mode 100644
index 0000000..ae9272e
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml
@@ -0,0 +1,13 @@
+import Music 1.0
+import Qt 4.7
+
+Item {
+
+ Musician {
+ id: reddy
+ name: "Reddy the Rocker"
+ instrument: Instrument { type: "Guitar" }
+ }
+
+ Component.onCompleted: console.log("Reddy plays the " + reddy.instrument.type)
+}
diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro
new file mode 100644
index 0000000..aea07a0
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro
@@ -0,0 +1,7 @@
+QT += declarative
+
+HEADERS += musician.h \
+ instrument.h
+SOURCES += musician.cpp \
+ instrument.cpp \
+ main.cpp
diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.cpp b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.cpp
new file mode 100644
index 0000000..13cd2fe
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "instrument.h"
+
+Instrument::Instrument(QObject *parent)
+ : QObject(parent)
+{
+}
+
+QString Instrument::type() const
+{
+ return m_type;
+}
+
+void Instrument::setType(const QString &type)
+{
+ m_type = type;
+}
+
diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.h b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.h
new file mode 100644
index 0000000..e2f09be
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef INSTRUMENT_H
+#define INSTRUMENT_H
+
+#include <QObject>
+
+//![0]
+class Instrument : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QString type READ type WRITE setType)
+
+public:
+ Instrument(QObject *parent = 0);
+
+ QString type() const;
+ void setType(const QString &type);
+
+private:
+ QString m_type;
+};
+//![0]
+
+#endif
+
diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp
new file mode 100644
index 0000000..cbbbc0f
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "musician.h"
+#include "instrument.h"
+
+#include <qdeclarative.h>
+#include <QDeclarativeView>
+#include <QApplication>
+
+//![0]
+int main(int argc, char *argv[])
+{
+//![0]
+ QApplication app(argc, argv);
+
+ qmlRegisterType<Musician>("Music", 1, 0, "Musician");
+
+//![1]
+ qmlRegisterType<Instrument>("Music", 1, 0, "Instrument");
+//![1]
+
+ QDeclarativeView view;
+ view.setSource(QUrl::fromLocalFile("app.qml"));
+ view.show();
+ return app.exec();
+
+//![2]
+}
+//![2]
diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/musician.cpp b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/musician.cpp
new file mode 100644
index 0000000..6b66d5d
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/musician.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "musician.h"
+#include "instrument.h"
+
+Musician::Musician(QObject *parent)
+ : QObject(parent)
+{
+}
+
+QString Musician::name() const
+{
+ return m_name;
+}
+
+void Musician::setName(const QString &name)
+{
+ m_name = name;
+}
+
+Instrument *Musician::instrument() const
+{
+ return m_instrument;
+}
+
+void Musician::setInstrument(Instrument *instrument)
+{
+ m_instrument = instrument;
+}
+
diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/musician.h b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/musician.h
new file mode 100644
index 0000000..d0aa118
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/musician.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef MUSICIAN_H
+#define MUSICIAN_H
+
+#include <QObject>
+
+class Instrument;
+
+//![0]
+class Musician : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(Instrument* instrument READ instrument WRITE setInstrument)
+//![0]
+ Q_PROPERTY(QString name READ name WRITE setName)
+
+//![1]
+public:
+//![1]
+
+ Musician(QObject *parent = 0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+//![2]
+ Instrument *instrument() const;
+ void setInstrument(Instrument *instrument);
+//![2]
+
+private:
+ QString m_name;
+ Instrument *m_instrument;
+
+//![3]
+};
+//![3]
+
+#endif
+
diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/app.qml b/examples/declarative/tutorials/extending/chapter5-plugins/app.qml
new file mode 100644
index 0000000..51c1232
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter5-plugins/app.qml
@@ -0,0 +1,13 @@
+import Qt 4.7
+
+Item {
+
+ Musician {
+ id: reddy
+ name: "Reddy the Rocker"
+ instrument: Instrument { type: "Guitar" }
+ }
+
+ Component.onCompleted: console.log("Reddy plays the " + reddy.instrument.type)
+}
+
diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/chapter5-plugins.pro b/examples/declarative/tutorials/extending/chapter5-plugins/chapter5-plugins.pro
new file mode 100644
index 0000000..7ec68e9
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter5-plugins/chapter5-plugins.pro
@@ -0,0 +1,15 @@
+TEMPLATE = lib
+CONFIG += qt plugin
+QT += declarative
+
+HEADERS += musician.h \
+ instrument.h \
+ musicplugin.h
+
+SOURCES += musician.cpp \
+ instrument.cpp \
+ musicplugin.cpp
+
+DESTDIR = lib
+OBJECTS_DIR = tmp
+MOC_DIR = tmp
diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/instrument.cpp b/examples/declarative/tutorials/extending/chapter5-plugins/instrument.cpp
new file mode 100644
index 0000000..13cd2fe
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter5-plugins/instrument.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "instrument.h"
+
+Instrument::Instrument(QObject *parent)
+ : QObject(parent)
+{
+}
+
+QString Instrument::type() const
+{
+ return m_type;
+}
+
+void Instrument::setType(const QString &type)
+{
+ m_type = type;
+}
+
diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/instrument.h b/examples/declarative/tutorials/extending/chapter5-plugins/instrument.h
new file mode 100644
index 0000000..15f9fae
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter5-plugins/instrument.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef INSTRUMENT_H
+#define INSTRUMENT_H
+
+#include <QObject>
+
+class Instrument : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QString type READ type WRITE setType)
+
+public:
+ Instrument(QObject *parent = 0);
+
+ QString type() const;
+ void setType(const QString &type);
+
+private:
+ QString m_type;
+};
+
+#endif
+
diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/musician.cpp b/examples/declarative/tutorials/extending/chapter5-plugins/musician.cpp
new file mode 100644
index 0000000..6b66d5d
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter5-plugins/musician.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "musician.h"
+#include "instrument.h"
+
+Musician::Musician(QObject *parent)
+ : QObject(parent)
+{
+}
+
+QString Musician::name() const
+{
+ return m_name;
+}
+
+void Musician::setName(const QString &name)
+{
+ m_name = name;
+}
+
+Instrument *Musician::instrument() const
+{
+ return m_instrument;
+}
+
+void Musician::setInstrument(Instrument *instrument)
+{
+ m_instrument = instrument;
+}
+
diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/musician.h b/examples/declarative/tutorials/extending/chapter5-plugins/musician.h
new file mode 100644
index 0000000..3c3eb2e
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter5-plugins/musician.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef MUSICIAN_H
+#define MUSICIAN_H
+
+#include <QObject>
+
+class Instrument;
+
+class Musician : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QString name READ name WRITE setName)
+ Q_PROPERTY(Instrument* instrument READ instrument WRITE setInstrument)
+
+public:
+ Musician(QObject *parent = 0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+ Instrument *instrument() const;
+ void setInstrument(Instrument *instrument);
+
+private:
+ QString m_name;
+ Instrument *m_instrument;
+};
+
+#endif
+
diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/musicplugin.cpp b/examples/declarative/tutorials/extending/chapter5-plugins/musicplugin.cpp
new file mode 100644
index 0000000..e2f6244
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter5-plugins/musicplugin.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "musicplugin.h"
+//![0]
+#include "musician.h"
+#include "instrument.h"
+#include <QtDeclarative/qdeclarative.h>
+
+void MusicPlugin::registerTypes(const char *uri)
+{
+ qmlRegisterType<Musician>(uri, 1, 0, "Musician");
+ qmlRegisterType<Instrument>(uri, 1, 0, "Instrument");
+}
+
+Q_EXPORT_PLUGIN2(musicplugin, MusicPlugin);
+//![0]
+
diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/musicplugin.h b/examples/declarative/tutorials/extending/chapter5-plugins/musicplugin.h
new file mode 100644
index 0000000..df8c9ab
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter5-plugins/musicplugin.h
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef MUSICPLUGIN_H
+#define MUSICPLUGIN_H
+
+//![0]
+#include <QtDeclarative/QDeclarativeExtensionPlugin>
+
+class MusicPlugin : public QDeclarativeExtensionPlugin
+{
+ Q_OBJECT
+public:
+ void registerTypes(const char *uri);
+};
+//![0]
+
+#endif
+
diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/qmldir b/examples/declarative/tutorials/extending/chapter5-plugins/qmldir
new file mode 100644
index 0000000..c3afd6b
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter5-plugins/qmldir
@@ -0,0 +1 @@
+plugin chapter5-plugins lib