summaryrefslogtreecommitdiffstats
path: root/doc/src
diff options
context:
space:
mode:
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/declarative/advtutorial.qdoc3
-rw-r--r--doc/src/declarative/declarativeui.qdoc2
-rw-r--r--doc/src/declarative/qdeclarativesecurity.qdoc2
-rw-r--r--doc/src/declarative/qmlruntime.qdoc46
-rw-r--r--doc/src/declarative/qtbinding.qdoc198
-rw-r--r--doc/src/declarative/qtdeclarative.qdoc7
-rw-r--r--doc/src/declarative/snippets/qtbinding/contextproperties/contextproperties.pro2
-rw-r--r--doc/src/declarative/snippets/qtbinding/contextproperties/main.cpp79
-rw-r--r--doc/src/declarative/snippets/qtbinding/contextproperties/main.qml15
-rw-r--r--doc/src/declarative/snippets/qtbinding/custompalette/custompalette.h80
-rw-r--r--doc/src/declarative/snippets/qtbinding/custompalette/custompalette.pro3
-rw-r--r--doc/src/declarative/snippets/qtbinding/custompalette/main.cpp62
-rw-r--r--doc/src/declarative/snippets/qtbinding/custompalette/main.qml22
-rw-r--r--doc/src/declarative/snippets/qtbinding/resources/example.qrc10
-rw-r--r--doc/src/declarative/snippets/qtbinding/resources/images/background.png0
-rw-r--r--doc/src/declarative/snippets/qtbinding/resources/main.cpp58
-rw-r--r--doc/src/declarative/snippets/qtbinding/resources/main.qml7
-rw-r--r--doc/src/declarative/snippets/qtbinding/resources/resources.pro4
-rw-r--r--doc/src/declarative/snippets/qtbinding/stopwatch/main.cpp63
-rw-r--r--doc/src/declarative/snippets/qtbinding/stopwatch/main.qml18
-rw-r--r--doc/src/declarative/snippets/qtbinding/stopwatch/stopwatch.cpp63
-rw-r--r--doc/src/declarative/snippets/qtbinding/stopwatch/stopwatch.h62
-rw-r--r--doc/src/declarative/snippets/qtbinding/stopwatch/stopwatch.pro3
23 files changed, 635 insertions, 174 deletions
diff --git a/doc/src/declarative/advtutorial.qdoc b/doc/src/declarative/advtutorial.qdoc
index 4807fd2..3a70eee 100644
--- a/doc/src/declarative/advtutorial.qdoc
+++ b/doc/src/declarative/advtutorial.qdoc
@@ -101,6 +101,9 @@ One item you may not recognize here
is the \l SystemPalette item. This provides access to the Qt system palette
and is used to give the button a more native look-and-feel.
+Notice the anchors for the \c Item, \c Button and \c Text elements are set using
+\l {Grouped Properties}{group notation} for readability.
+
\section2 Adding \c Button and \c Block components
The \c Button item in the code above is defined in a separate file named \c Button.qml.
diff --git a/doc/src/declarative/declarativeui.qdoc b/doc/src/declarative/declarativeui.qdoc
index a4f4bc7..a2a5283 100644
--- a/doc/src/declarative/declarativeui.qdoc
+++ b/doc/src/declarative/declarativeui.qdoc
@@ -77,6 +77,7 @@ completely new applications. QML is fully \l {Extending QML in C++}{extensible
\o \l {QML Advanced Tutorial}{Tutorial: 'Same Game'}
\o \l {QML Examples and Walkthroughs}
\o \l {Using QML in C++ Applications}
+\o \l {QML for Qt programmers}
\endlist
\section1 Core QML Features:
@@ -102,6 +103,7 @@ completely new applications. QML is fully \l {Extending QML in C++}{extensible
\o \l {QML Elements}
\o \l {QML Global Object}
\o \l {Extending QML in C++}
+\o \l {Integrating QML with existing Qt UI code}
\o \l {QML Internationalization}
\o \l {QML Security}
\o \l {QtDeclarative Module}
diff --git a/doc/src/declarative/qdeclarativesecurity.qdoc b/doc/src/declarative/qdeclarativesecurity.qdoc
index ab75a57..290d78f 100644
--- a/doc/src/declarative/qdeclarativesecurity.qdoc
+++ b/doc/src/declarative/qdeclarativesecurity.qdoc
@@ -70,7 +70,7 @@ perform appropriate checks on untrusted data it loads.
A non-exhaustive list of the ways you could shoot yourself in the foot is:
\list
- \i Using \c import to import QML or JavaScropt you do not control. BAD
+ \i Using \c import to import QML or JavaScript you do not control. BAD
\i Using \l Loader to import QML you do not control. BAD
\i Using \l{XMLHttpRequest()}{XMLHttpRequest} to load data you do not control and executing it. BAD
\endlist
diff --git a/doc/src/declarative/qmlruntime.qdoc b/doc/src/declarative/qmlruntime.qdoc
index 8bb3ec7..fbe82c6 100644
--- a/doc/src/declarative/qmlruntime.qdoc
+++ b/doc/src/declarative/qmlruntime.qdoc
@@ -70,7 +70,7 @@
\code
qml myQmlFile.qml
\endcode
-
+
Deploying a QML application via the \c qml executable allows for QML only deployments, but can also
include custom C++ modules just as easily. Below is an example of how you might structure
a complex application deployed via the qml runtime, it is a listing of the files that would
@@ -101,7 +101,7 @@
import "MyAppCore"
import "OtherModule" 1.0 as Other
\endcode
-
+
\section1 \c qml application functionality
The \c qml application implements some additional functionality to help it serve the role of a launcher
for myriad applications. If you implement your own launcher application, you may also wish to reimplement
@@ -134,23 +134,25 @@
Any QML can be used in the dummy data files. You could even animate the
fictional data!
- \section2 Screen Orientation
+ \section2 Runtime Object
+
+ All applications using the qmlruntime will have access to the 'runtime'
+ property on the root context. This property contains several information
+ about the runtime environment of the application.
+
+ \section3 Screen Orientation
A special piece of dummy data which is integrated into the runtime is
a simple orientation property. The orientation can be set via the
settings menu in the application, or by pressing Ctrl+T to toggle it.
- To use this from within your QML file, import QDeclarativeViewer 1.0 and create a
- Screen object. This object has a property, orientation, which can be either
- Screen.Landscape or Screen.Portrait and which can be bound to in your
+ To use this from within your QML file, access runtime.orientation,
+ which can be either Orientation.Landscape or Orientation.Portrait and which can be bound to in your
application. An example is below:
\code
- import QDeclarativeViewer 1.0 as QDeclarativeViewer
-
Item {
- QDeclarativeViewer.Screen { id: screen }
- state: (screen.orientation == QDeclarativeViewer.Screen.Landscape) ? 'landscape' : ''
+ state: (runtime.orientation == Orientation.Landscape) ? 'landscape' : ''
}
\endcode
@@ -158,4 +160,28 @@
will automatically update this on some platforms (currently the N900 only) to match the physical
screen's orientation. On other plaforms orientation changes will only happen when explictly asked for.
+ \section3 Window Active
+
+ The runtime.isActiveWindow property tells whether the main window of the qml runtime is currently active
+ or not. This is specially useful for embedded devices when you want to pause parts of your application,
+ including animations, when your application looses focus or goes to the background.
+
+ The example below, stops the animation when the application's window is deactivated and resumes on activation:
+
+\code
+ Item {
+ width: 300; height: 200
+ Rectangle {
+ width: 100; height: 100
+ color: "green"
+ SequentialAnimation on x {
+ running: runtime.isActiveWindow
+ loops: Animation.Infinite
+ NumberAnimation {to: 200}
+ NumberAnimation {to: 0}
+ }
+ }
+ }
+\endcode
+
*/
diff --git a/doc/src/declarative/qtbinding.qdoc b/doc/src/declarative/qtbinding.qdoc
index 181c504..d024ff2 100644
--- a/doc/src/declarative/qtbinding.qdoc
+++ b/doc/src/declarative/qtbinding.qdoc
@@ -73,9 +73,9 @@ QML component instances can then be created by calling the QDeclarativeComponent
an example of loading a QML document, and creating an object from it.
\code
-QDeclarativeEngine *engine = new QDeclarativeEngine(parent);
-QDeclarativeComponent component(engine, QUrl("main.qml"));
-QObject *myObject = component.create();
+ QDeclarativeEngine *engine = new QDeclarativeEngine(parent);
+ QDeclarativeComponent component(engine, QUrl::fromLocalFile("main.qml"));
+ QObject *myObject = component.create();
\endcode
\section1 Exposing Data
@@ -91,40 +91,28 @@ the root context is available to all object instances.
To expose data to a QML component instance, applications set \l {QDeclarativeContext::setContextProperty()}
{context properties} which are then accessible by name from QML \l {Property Binding}s and JavaScript.
-The following example shows how to expose a background color to a QML file.
+The following example shows how to expose a background color to a QML file through QDeclarativeView:
\table
\row
\o
-\code
-// main.cpp
-QDeclarativeContext *windowContext = new QDeclarativeContext(engine->rootContext());
-windowContext->setContextProperty("backgroundColor",
- QColor(Qt::lightsteelblue));
+\c {// main.cpp}
+\snippet doc/src/declarative/snippets/qtbinding/contextproperties/main.cpp 0
-QDeclarativeComponent component(&engine, "main.qml");
-QObject *window = component.create(windowContext);
-\endcode
\o
-\code
-// main.qml
-import Qt 4.7
+\c {// main.qml}
+\snippet doc/src/declarative/snippets/qtbinding/contextproperties/main.qml 0
-Rectangle {
- color: backgroundColor
-
- Text {
- anchors.centerIn: parent
- text: "Hello Light Steel Blue World!"
- }
-}
-\endcode
\endtable
+Or, if you want \c main.cpp to create the component without showing it in a QDeclarativeView, you could create an instance of QDeclarativeContext using QDeclarativeEngine::rootContext() instead:
+
+\snippet doc/src/declarative/snippets/qtbinding/contextproperties/main.cpp 1
+
Context properties work just like normal properties in QML bindings - if the \c backgroundColor
-context property in the previous example was changed to red, the component object instances would
+context property in this example was changed to red, the component object instances would
all be automatically updated. Note that it is the responsibility of the creator to delete any
-QDeclarativeContext it constructs. If the \c windowContext in the example above is no longer needed when
+QDeclarativeContext it constructs. If the \c windowContext is no longer needed when
the \c window component instantiation is destroyed, the \c windowContext must be destroyed
explicitly. The simplest way to ensure this is to set \c window as \c windowContext's parent.
@@ -147,78 +135,15 @@ allow QML to set values.
The following example creates a \c CustomPalette object, and sets it as the \c palette context
property.
-\code
-class CustomPalette : public QObject
-{
-Q_OBJECT
-Q_PROPERTY(QColor background READ background WRITE setBackground NOTIFY backgroundChanged)
-Q_PROPERTY(QColor text READ text WRITE setText NOTIFY textChanged)
-public:
- CustomPalette() : m_background(Qt::white), m_text(Qt::black) {}
-
- QColor background() const { return m_background; }
- void setBackground(const QColor &c) {
- if (c != m_background) {
- m_background = c;
- emit backgroundChanged();
- }
- }
-
- QColor text() const { return m_text; }
- void setText(const QColor &c) {
- if (c != m_text) {
- m_text = c;
- emit textChanged();
- }
- }
-signals:
- void textChanged();
- void backgroundChanged():
-
-private:
- QColor m_background;
- QColor m_text;
-};
+\snippet doc/src/declarative/snippets/qtbinding/custompalette/custompalette.h 0
-int main(int argc, char **argv)
-{
- // ...
-
- QDeclarativeContext *windowContext = new QDeclarativeContext(engine->rootContext());
- windowContext->setContextProperty("palette", new CustomPalette);
-
- QDeclarativeComponent component(&engine, "main.qml");
- QObject *window = component.create(windowContext);
-}
-\endcode
+\snippet doc/src/declarative/snippets/qtbinding/custompalette/main.cpp 0
The QML that follows references the palette object, and its properties, to set the appropriate
background and text colors. When the window is clicked, the palette's text color is changed, and
the window text will update accordingly.
-\code
-// main.qml
-import Qt 4.7
-
-Rectangle {
- width: 240
- height: 320
- color: palette.background
-
- Text {
- anchors.centerIn: parent
- color: palette.text
- text: "Hello Colorful World!"
- }
-
- MouseArea {
- anchors.fill: parent
- onClicked: {
- palette.text = "blue";
- }
- }
-}
-\endcode
+\snippet doc/src/declarative/snippets/qtbinding/custompalette/main.qml 0
To detect when a C++ property value - in this case the \c CustomPalette's \c text property -
changes, the property must have a corresponding NOTIFY signal. The NOTIFY signal specifies a signal
@@ -254,57 +179,23 @@ the following types:
\o QVariant
\endlist
-This example toggles the "LED Blinker" when the MouseArea is clicked:
+This example toggles the "Stopwatch" object on/off when the MouseArea is clicked:
\table
\row
\o
-\code
-// main.cpp
-class LEDBlinker : public QObject
-{
- Q_OBJECT
-public:
- LEDBlinker();
-
- Q_INVOKABLE bool isRunning();
+\c {// main.cpp}
+\snippet doc/src/declarative/snippets/qtbinding/stopwatch/stopwatch.h 0
+\snippet doc/src/declarative/snippets/qtbinding/stopwatch/main.cpp 0
-public slots:
- void start();
- void stop();
-};
-
-int main(int argc, char **argv)
-{
- // ...
-
- QDeclarativeContext *context = engine->rootContext();
- context->setContextProperty("ledBlinker", new LEDBlinker);
-
- // ...
-}
-\endcode
\o
-\code
-// main.qml
-import Qt 4.7
+\c {// main.qml}
+\snippet doc/src/declarative/snippets/qtbinding/stopwatch/main.qml 0
-Rectangle {
- MouseArea {
- anchors.fill: parent
- onClicked: {
- if (ledBlinker.isRunning())
- ledBlinker.stop()
- else
- ledBlicker.start();
- }
- }
-}
-\endcode
\endtable
Note that in this particular example a better way to achieve the same result
-is to have a "running" property. This leads to much nicer QML code:
+is to have a "running" property in \c main.qml. This leads to much nicer QML code:
\table
\row
@@ -316,13 +207,12 @@ import Qt 4.7
Rectangle {
MouseArea {
anchors.fill: parent
- onClicked: ledBlinker.running = !ledBlinker.running
+ onClicked: stopwatch.running = !stopwatch.running
}
}
\endcode
\endtable
-
Of course, it is also possible to call \l {Adding new methods}{functions declared in QML from C++}.
@@ -367,35 +257,17 @@ void MyApplication::continueLoading()
QML content can be loaded from \l {The Qt Resource System} using the \e qrc: URL scheme.
For example:
-\code
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>main.qml</file>
- <file>images/background.png</file>
-</qresource>
-</RCC>
-\endcode
-\code
-// main.cpp
-MyApplication::MyApplication()
-{
- // ...
- component = new QDeclarativeComponent(engine, QUrl("qrc:/main.qml"));
- if (component->isError()) {
- qWarning() << component->errors();
- } else {
- QObject *myObject = component->create();
- }
-}
-\endcode
-\code
-// main.qml
-import Qt 4.7
+\c [project/example.qrc]
+\quotefile doc/src/declarative/snippets/qtbinding/resources/example.qrc
-Image {
- source: "images/background.png"
-}
-\endcode
+\c [project/project.pro]
+\quotefile doc/src/declarative/snippets/qtbinding/resources/resources.pro
+
+\c [project/main.cpp]
+\snippet doc/src/declarative/snippets/qtbinding/resources/main.cpp 0
+
+\c [project/main.qml]
+\snippet doc/src/declarative/snippets/qtbinding/resources/main.qml 0
*/
diff --git a/doc/src/declarative/qtdeclarative.qdoc b/doc/src/declarative/qtdeclarative.qdoc
index 8013b92..cbb2146 100644
--- a/doc/src/declarative/qtdeclarative.qdoc
+++ b/doc/src/declarative/qtdeclarative.qdoc
@@ -69,6 +69,10 @@
/*!
\macro QML_DECLARE_TYPE()
\relates QDeclarativeEngine
+
+ Declares a C++ type to be usable in the QML system. In addition
+ to this, a type must also be registered with the QML system using
+ qmlRegisterType().
*/
@@ -79,6 +83,7 @@
This template function registers the C++ type in the QML system with
the name \a qmlName. in the library imported from \a uri having the
version number composed from \a versionMajor and \a versionMinor.
+ The type should also haved been declared with the QML_DECLARE_TYPE() macro.
Returns the QML type id.
@@ -109,6 +114,8 @@
This template function registers the C++ type in the QML system
under the name \a typeName.
+ The type should also haved been declared with the QML_DECLARE_TYPE() macro.
+
Returns the QML type id.
*/
diff --git a/doc/src/declarative/snippets/qtbinding/contextproperties/contextproperties.pro b/doc/src/declarative/snippets/qtbinding/contextproperties/contextproperties.pro
new file mode 100644
index 0000000..68eeaf2
--- /dev/null
+++ b/doc/src/declarative/snippets/qtbinding/contextproperties/contextproperties.pro
@@ -0,0 +1,2 @@
+QT += declarative
+SOURCES += main.cpp
diff --git a/doc/src/declarative/snippets/qtbinding/contextproperties/main.cpp b/doc/src/declarative/snippets/qtbinding/contextproperties/main.cpp
new file mode 100644
index 0000000..15e3d4c
--- /dev/null
+++ b/doc/src/declarative/snippets/qtbinding/contextproperties/main.cpp
@@ -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$
+**
+****************************************************************************/
+
+#include <QDeclarativeComponent>
+#include <QDeclarativeEngine>
+
+//![0]
+#include <QApplication>
+#include <QDeclarativeView>
+#include <QDeclarativeContext>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ QDeclarativeView view;
+ QDeclarativeContext *context = view.rootContext();
+ context->setContextProperty("backgroundColor",
+ QColor(Qt::yellow));
+
+ view.setSource(QUrl("main.qml"));
+ view.show();
+
+ return app.exec();
+}
+//![0]
+
+static void alternative()
+{
+ // Alternatively, if we don't actually want to display main.qml:
+//![1]
+ QDeclarativeEngine engine;
+ QDeclarativeContext *windowContext = new QDeclarativeContext(engine.rootContext());
+ windowContext->setContextProperty("backgroundColor", QColor(Qt::yellow));
+
+ QDeclarativeComponent component(&engine, "main.qml");
+ QObject *window = component.create(windowContext);
+//![1]
+}
+
+
diff --git a/doc/src/declarative/snippets/qtbinding/contextproperties/main.qml b/doc/src/declarative/snippets/qtbinding/contextproperties/main.qml
new file mode 100644
index 0000000..1053f73
--- /dev/null
+++ b/doc/src/declarative/snippets/qtbinding/contextproperties/main.qml
@@ -0,0 +1,15 @@
+//![0]
+import Qt 4.7
+
+Rectangle {
+ width: 300
+ height: 300
+
+ color: backgroundColor
+
+ Text {
+ anchors.centerIn: parent
+ text: "Hello Yellow World!"
+ }
+}
+//![0]
diff --git a/doc/src/declarative/snippets/qtbinding/custompalette/custompalette.h b/doc/src/declarative/snippets/qtbinding/custompalette/custompalette.h
new file mode 100644
index 0000000..d0d253a
--- /dev/null
+++ b/doc/src/declarative/snippets/qtbinding/custompalette/custompalette.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** 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 <QObject>
+#include <QColor>
+
+//![0]
+class CustomPalette : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QColor background READ background WRITE setBackground NOTIFY backgroundChanged)
+ Q_PROPERTY(QColor text READ text WRITE setText NOTIFY textChanged)
+
+public:
+ CustomPalette() : m_background(Qt::white), m_text(Qt::black) {}
+
+ QColor background() const { return m_background; }
+ void setBackground(const QColor &c) {
+ if (c != m_background) {
+ m_background = c;
+ emit backgroundChanged();
+ }
+ }
+
+ QColor text() const { return m_text; }
+ void setText(const QColor &c) {
+ if (c != m_text) {
+ m_text = c;
+ emit textChanged();
+ }
+ }
+
+signals:
+ void textChanged();
+ void backgroundChanged();
+
+private:
+ QColor m_background;
+ QColor m_text;
+};
+
+//![0]
diff --git a/doc/src/declarative/snippets/qtbinding/custompalette/custompalette.pro b/doc/src/declarative/snippets/qtbinding/custompalette/custompalette.pro
new file mode 100644
index 0000000..e6af0d0
--- /dev/null
+++ b/doc/src/declarative/snippets/qtbinding/custompalette/custompalette.pro
@@ -0,0 +1,3 @@
+QT += declarative
+HEADERS += custompalette.h
+SOURCES += main.cpp
diff --git a/doc/src/declarative/snippets/qtbinding/custompalette/main.cpp b/doc/src/declarative/snippets/qtbinding/custompalette/main.cpp
new file mode 100644
index 0000000..c723688
--- /dev/null
+++ b/doc/src/declarative/snippets/qtbinding/custompalette/main.cpp
@@ -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$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QDeclarativeView>
+#include <QDeclarativeContext>
+
+#include "custompalette.h"
+
+//![0]
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ QDeclarativeView view;
+ view.rootContext()->setContextProperty("palette", new CustomPalette);
+
+ view.setSource(QUrl("main.qml"));
+ view.show();
+
+ return app.exec();
+}
+//![0]
+
diff --git a/doc/src/declarative/snippets/qtbinding/custompalette/main.qml b/doc/src/declarative/snippets/qtbinding/custompalette/main.qml
new file mode 100644
index 0000000..f1a3b4f
--- /dev/null
+++ b/doc/src/declarative/snippets/qtbinding/custompalette/main.qml
@@ -0,0 +1,22 @@
+//![0]
+import Qt 4.7
+
+Rectangle {
+ width: 240
+ height: 320
+ color: palette.background
+
+ Text {
+ anchors.centerIn: parent
+ color: palette.text
+ text: "Click me to change color!"
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ palette.text = "blue";
+ }
+ }
+}
+//![0]
diff --git a/doc/src/declarative/snippets/qtbinding/resources/example.qrc b/doc/src/declarative/snippets/qtbinding/resources/example.qrc
new file mode 100644
index 0000000..5e49415
--- /dev/null
+++ b/doc/src/declarative/snippets/qtbinding/resources/example.qrc
@@ -0,0 +1,10 @@
+<!DOCTYPE RCC>
+<RCC version="1.0">
+
+<qresource prefix="/">
+ <file>main.qml</file>
+ <file>images/background.png</file>
+</qresource>
+
+</RCC>
+
diff --git a/doc/src/declarative/snippets/qtbinding/resources/images/background.png b/doc/src/declarative/snippets/qtbinding/resources/images/background.png
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/doc/src/declarative/snippets/qtbinding/resources/images/background.png
diff --git a/doc/src/declarative/snippets/qtbinding/resources/main.cpp b/doc/src/declarative/snippets/qtbinding/resources/main.cpp
new file mode 100644
index 0000000..5459b9e
--- /dev/null
+++ b/doc/src/declarative/snippets/qtbinding/resources/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$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QDeclarativeView>
+#include <QDeclarativeContext>
+
+//![0]
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ QDeclarativeView view;
+ view.setSource(QUrl("qrc:/main.qml"));
+ view.show();
+
+ return app.exec();
+}
+//![0]
+
diff --git a/doc/src/declarative/snippets/qtbinding/resources/main.qml b/doc/src/declarative/snippets/qtbinding/resources/main.qml
new file mode 100644
index 0000000..dfe923f
--- /dev/null
+++ b/doc/src/declarative/snippets/qtbinding/resources/main.qml
@@ -0,0 +1,7 @@
+//![0]
+import Qt 4.7
+
+Image {
+ source: "images/background.png"
+}
+//![0]
diff --git a/doc/src/declarative/snippets/qtbinding/resources/resources.pro b/doc/src/declarative/snippets/qtbinding/resources/resources.pro
new file mode 100644
index 0000000..cc01ee1
--- /dev/null
+++ b/doc/src/declarative/snippets/qtbinding/resources/resources.pro
@@ -0,0 +1,4 @@
+QT += declarative
+
+SOURCES += main.cpp
+RESOURCES += example.qrc
diff --git a/doc/src/declarative/snippets/qtbinding/stopwatch/main.cpp b/doc/src/declarative/snippets/qtbinding/stopwatch/main.cpp
new file mode 100644
index 0000000..13e3b9f
--- /dev/null
+++ b/doc/src/declarative/snippets/qtbinding/stopwatch/main.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** 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 "stopwatch.h"
+
+#include <QDeclarativeView>
+#include <QDeclarativeContext>
+#include <QApplication>
+
+//![0]
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ QDeclarativeView view;
+ view.rootContext()->setContextProperty("stopwatch",
+ new Stopwatch);
+
+ view.setSource(QUrl("main.qml"));
+ view.show();
+
+ return app.exec();
+}
+//![0]
+
diff --git a/doc/src/declarative/snippets/qtbinding/stopwatch/main.qml b/doc/src/declarative/snippets/qtbinding/stopwatch/main.qml
new file mode 100644
index 0000000..2efa542
--- /dev/null
+++ b/doc/src/declarative/snippets/qtbinding/stopwatch/main.qml
@@ -0,0 +1,18 @@
+//![0]
+import Qt 4.7
+
+Rectangle {
+ width: 300
+ height: 300
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ if (stopwatch.isRunning())
+ stopwatch.stop()
+ else
+ stopwatch.start();
+ }
+ }
+}
+//![0]
diff --git a/doc/src/declarative/snippets/qtbinding/stopwatch/stopwatch.cpp b/doc/src/declarative/snippets/qtbinding/stopwatch/stopwatch.cpp
new file mode 100644
index 0000000..4954a5f
--- /dev/null
+++ b/doc/src/declarative/snippets/qtbinding/stopwatch/stopwatch.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** 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 "stopwatch.h"
+
+Stopwatch::Stopwatch()
+ : m_running(false)
+{
+}
+
+bool Stopwatch::isRunning() const
+{
+ return m_running;
+}
+
+void Stopwatch::start()
+{
+ m_running = true;
+}
+
+void Stopwatch::stop()
+{
+ m_running = false;
+}
+
diff --git a/doc/src/declarative/snippets/qtbinding/stopwatch/stopwatch.h b/doc/src/declarative/snippets/qtbinding/stopwatch/stopwatch.h
new file mode 100644
index 0000000..8d17121
--- /dev/null
+++ b/doc/src/declarative/snippets/qtbinding/stopwatch/stopwatch.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$
+**
+****************************************************************************/
+
+#include <QObject>
+
+//![0]
+class Stopwatch : public QObject
+{
+ Q_OBJECT
+public:
+ Stopwatch();
+
+ Q_INVOKABLE bool isRunning() const;
+
+public slots:
+ void start();
+ void stop();
+
+private:
+ bool m_running;
+};
+
+//![0]
+
diff --git a/doc/src/declarative/snippets/qtbinding/stopwatch/stopwatch.pro b/doc/src/declarative/snippets/qtbinding/stopwatch/stopwatch.pro
new file mode 100644
index 0000000..d803e6a
--- /dev/null
+++ b/doc/src/declarative/snippets/qtbinding/stopwatch/stopwatch.pro
@@ -0,0 +1,3 @@
+QT += declarative
+HEADERS += stopwatch.h
+SOURCES += main.cpp stopwatch.cpp