summaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorDavid Boddie <dboddie@trolltech.com>2010-05-06 20:26:59 +0200
committerDavid Boddie <dboddie@trolltech.com>2010-05-06 20:26:59 +0200
commit109024630cbf577d6f6bcb10ea3ac6272113b79e (patch)
tree92dcb243f3ac3cadb1efdc7a3a646f880c544955 /doc
parenta182cc5d5d7a70d0423a42123bb7c1cf21709e0d (diff)
parent4a934cb8bb610119367f918957d871fbbc2799ff (diff)
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7
Diffstat (limited to 'doc')
-rw-r--r--doc/src/classes.qdoc4
-rw-r--r--doc/src/declarative/advtutorial.qdoc19
-rw-r--r--doc/src/declarative/anchor-layout.qdoc8
-rw-r--r--doc/src/declarative/animation.qdoc2
-rw-r--r--doc/src/declarative/declarativeui.qdoc11
-rw-r--r--doc/src/declarative/elements.qdoc1
-rw-r--r--doc/src/declarative/examples.qdoc40
-rw-r--r--doc/src/declarative/extending-tutorial.qdoc420
-rw-r--r--doc/src/declarative/extending.qdoc39
-rw-r--r--doc/src/declarative/globalobject.qdoc4
-rw-r--r--doc/src/declarative/integrating.qdoc4
-rw-r--r--doc/src/declarative/javascriptblocks.qdoc17
-rw-r--r--doc/src/declarative/measuring-performance.qdoc122
-rw-r--r--doc/src/declarative/network.qdoc11
-rw-r--r--doc/src/declarative/qdeclarativedocument.qdoc2
-rw-r--r--doc/src/declarative/qdeclarativei18n.qdoc2
-rw-r--r--doc/src/declarative/qdeclarativeintro.qdoc4
-rw-r--r--doc/src/declarative/qdeclarativestates.qdoc2
-rw-r--r--doc/src/declarative/qmlruntime.qdoc16
-rw-r--r--doc/src/declarative/qtprogrammers.qdoc4
-rw-r--r--doc/src/declarative/snippets/qtbinding/contextproperties/main.cpp2
-rw-r--r--doc/src/declarative/snippets/qtbinding/custompalette/main.cpp2
-rw-r--r--doc/src/declarative/snippets/qtbinding/stopwatch/main.cpp2
-rw-r--r--doc/src/examples/dragdroprobot.qdoc334
-rw-r--r--doc/src/examples/elasticnodes.qdoc391
-rw-r--r--doc/src/examples/qml-examples.qdoc260
-rw-r--r--doc/src/examples/qml-focus.qdoc49
-rw-r--r--doc/src/getting-started/examples.qdoc4
-rw-r--r--doc/src/getting-started/installation.qdoc203
-rw-r--r--doc/src/platforms/platform-notes.qdoc29
-rw-r--r--doc/src/snippets/code/doc_src_installation.qdoc86
31 files changed, 1834 insertions, 260 deletions
diff --git a/doc/src/classes.qdoc b/doc/src/classes.qdoc
index 6ba31a2f29..1552f567c9 100644
--- a/doc/src/classes.qdoc
+++ b/doc/src/classes.qdoc
@@ -59,7 +59,7 @@
/*!
\page classes.html
- \title All Qt Classes (main index)
+ \title All Qt Classes
\ingroup classlists
\brief If you know the name of the class you want, find it here.
@@ -146,7 +146,7 @@
/*!
\page functions.html
- \title All Functions (main index)
+ \title All Functions
\ingroup funclists
\brief All documented Qt functions listed alphabetically with a
diff --git a/doc/src/declarative/advtutorial.qdoc b/doc/src/declarative/advtutorial.qdoc
index c465da4030..2d05850c6e 100644
--- a/doc/src/declarative/advtutorial.qdoc
+++ b/doc/src/declarative/advtutorial.qdoc
@@ -66,13 +66,13 @@ control QML elements.
Tutorial chapters:
\list 1
-\o \l {QML Advanced Tutorial 1 - Creating the Game Canvas and Blocks}{Creating the Game Canvas and Blocks}
-\o \l {QML Advanced Tutorial 2 - Populating the Game Canvas}{Populating the Game Canvas}
-\o \l {QML Advanced Tutorial 3 - Implementing the Game Logic}{Implementing the Game Logic}
-\o \l {QML Advanced Tutorial 4 - Finishing Touches}{Finishing Touches}
+\o \l {declarative/tutorials/samegame/samegame1}{Creating the Game Canvas and Blocks}
+\o \l {declarative/tutorials/samegame/samegame2}{Populating the Game Canvas}
+\o \l {declarative/tutorials/samegame/samegame3}{Implementing the Game Logic}
+\o \l {declarative/tutorials/samegame/samegame4}{Finishing Touches}
\endlist
-All the code in this tutorial can be found in the $QTDIR/examples/declarative/tutorials/samegame
+All the code in this tutorial can be found in Qt's \c examples/declarative/tutorials/samegame
directory.
*/
@@ -83,7 +83,7 @@ directory.
\previouspage QML Advanced Tutorial
\nextpage QML Advanced Tutorial 2 - Populating the Game Canvas
-The files referenced on this page can be found in \c $QTDIR\examples\tutorials\samegame\samegame1.
+\example declarative/tutorials/samegame/samegame1
\section2 Creating the application screen
@@ -148,8 +148,7 @@ elements to get started. Next, we will populate the game canvas with some blocks
\previouspage QML Advanced Tutorial 1 - Creating the Game Canvas and Blocks
\nextpage QML Advanced Tutorial 3 - Implementing the Game Logic
-The files referenced on this page can be found in \c $QTDIR\examples\tutorials\samegame\samegame2.
-
+\example declarative/tutorials/samegame/samegame2
\section2 Generating the blocks in JavaScript
@@ -216,7 +215,7 @@ Now, we have a screen of blocks, and we can begin to add the game mechanics.
\previouspage QML Advanced Tutorial 2 - Populating the Game Canvas
\nextpage QML Advanced Tutorial 4 - Finishing Touches
-The files referenced on this page can be found in \c $QTDIR\examples\tutorials\samegame\samegame3.
+\example declarative/tutorials/samegame/samegame3
\section2 Making a playable game
@@ -301,7 +300,7 @@ until the next chapter - where your application becomes alive!
\contentspage QML Advanced Tutorial
\previouspage QML Advanced Tutorial 3 - Implementing the Game Logic
-The files referenced on this page can be found in \c $QTDIR\examples\tutorials\samegame\samegame4.
+\example declarative/tutorials/samegame/samegame4
\section2 Adding some flair
diff --git a/doc/src/declarative/anchor-layout.qdoc b/doc/src/declarative/anchor-layout.qdoc
index ff4769474b..5340de6562 100644
--- a/doc/src/declarative/anchor-layout.qdoc
+++ b/doc/src/declarative/anchor-layout.qdoc
@@ -44,10 +44,16 @@
\target anchor-layout
\title Anchor-based Layout in QML
-In addition to the more traditional \l Grid, \l Row, and \l Column, QML also provides a way to layout items using the concept of \e anchors. Each item can be thought of as having a set of 6 invisible "anchor lines": \e left, \e horizontalCenter, \e right, \e top, \e verticalCenter, and \e bottom.
+In addition to the more traditional \l Grid, \l Row, and \l Column,
+QML also provides a way to layout items using the concept of \e anchors.
+Each item can be thought of as having a set of 7 invisible "anchor lines":
+\e left, \e horizontalCenter, \e right, \e top, \e verticalCenter, \e baseline, and \e bottom.
\image edges_qml.png
+The baseline (not pictured above) corresponds to the imaginary line on which
+text would sit. For items with no text it is the same as \e top.
+
The QML anchoring system allows you to define relationships between the anchor lines of different items. For example, you can write:
\code
diff --git a/doc/src/declarative/animation.qdoc b/doc/src/declarative/animation.qdoc
index 9969e8f269..88aca1b30c 100644
--- a/doc/src/declarative/animation.qdoc
+++ b/doc/src/declarative/animation.qdoc
@@ -94,7 +94,7 @@ Rectangle {
Rectangle {
color: "red"
width: 50; height: 50
- NumberAnimation on x { to: 50; }
+ NumberAnimation on x { to: 50 }
}
}
\endqml
diff --git a/doc/src/declarative/declarativeui.qdoc b/doc/src/declarative/declarativeui.qdoc
index 3ee7fc1c28..d79c4d238e 100644
--- a/doc/src/declarative/declarativeui.qdoc
+++ b/doc/src/declarative/declarativeui.qdoc
@@ -85,7 +85,6 @@ completely new applications. QML is fully \l {Extending QML in C++}{extensible
\o \l {QML Tutorial}{Tutorial: 'Hello World'}
\o \l {QML Advanced Tutorial}{Tutorial: 'Same Game'}
\o \l {QML Examples and Demos}
-\o \l {Using QML in C++ Applications}
\o \l {QML for Qt programmers}
\endlist
@@ -107,12 +106,18 @@ completely new applications. QML is fully \l {Extending QML in C++}{extensible
\o \l {qmlruntime.html}{The Qt Declarative Runtime}
\endlist
+\section1 Using QML with C++:
+\list
+\o \l {Tutorial: Writing QML extensions with C++}
+\o \l {Extending QML in C++}
+\o \l {Using QML in C++ Applications}
+\o \l {Integrating QML with existing Qt UI code}
+\endlist
+
\section1 Reference:
\list
\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/elements.qdoc b/doc/src/declarative/elements.qdoc
index 6495f586da..79fe90996d 100644
--- a/doc/src/declarative/elements.qdoc
+++ b/doc/src/declarative/elements.qdoc
@@ -122,6 +122,7 @@ The following table lists the QML elements provided by the \l {QtDeclarative}{Qt
\o \l Rectangle
\o \l Image
\o \l BorderImage
+\o \l AnimatedImage
\o \l Text
\o \l TextInput
\o \l TextEdit
diff --git a/doc/src/declarative/examples.qdoc b/doc/src/declarative/examples.qdoc
index dc6b76c877..e01459f690 100644
--- a/doc/src/declarative/examples.qdoc
+++ b/doc/src/declarative/examples.qdoc
@@ -71,7 +71,47 @@ For example, from your build directory, run:
\section1 Examples
\list
+\o \l{declarative/animations}{Animations}
+\o \l{declarative/aspectratio}{Aspect Ratio}
+\o \l{declarative/behaviors}{Behaviors}
+\o \l{declarative/border-image}{Border Image}
+\o \l{declarative/clocks}{Clocks}
+\o \l{declarative/connections}{Connections}
+\o \l{declarative/dial}{Dial}
+\o \l{declarative/dynamic}{Dynamic}
+\o \l{declarative/extending}{Extending}
+\o \l{declarative/fillmode}{Fillmode}
+\o \l{declarative/flipable}{Flipable}
\o \l{declarative/focus}{Focus}
+\o \l{declarative/fonts}{Fonts}
+\o \l{declarative/gridview}{GridView}
+\o \l{declarative/imageprovider}{Image Provider}
+\o \l{declarative/images}{Images}
+\o \l{declarative/layouts}{Layouts}
+\o \l{declarative/listmodel-threaded}{ListModel Threaded}
+\o \l{declarative/listview}{ListView}
+\o \l{declarative/mousearea}{Mouse Area}
+\o \l{declarative/objectlistmodel}{Object ListModel}
+\o \l{declarative/package}{Package}
+\o \l{declarative/parallax}{Parallax}
+\o \l{declarative/plugins}{Plugins}
+\o \l{declarative/progressbar}{Progress Bars}
+\o \l{declarative/proxywidgets}{Proxy Widgets}
+\o \l{declarative/scrollbar}{Scrollbar}
+\o \l{declarative/searchbox}{Search Box}
+\o \l{declarative/slideswitch}{Slide Switch}
+\o \l{declarative/sql}{SQL}
+\o \l{declarative/states}{States}
+\o \l{declarative/stringlistmodel}{String ListModel}
+\o \l{declarative/tabwidget}{Tab Widget}
+\o \l{declarative/tic-tac-toe}{Tic-Tac-Toe}
+\o \l{declarative/tvtennis}{TV Tennis}
+\o \l{declarative/velocity}{Velocity}
+\o \l{declarative/webview}{WebView}
+\o \l{declarative/workerscript}{WorkerScript}
+\o \l{declarative/xmldata}{XML Data}
+\o \l{declarative/xmlhttprequest}{XMLHttpRequest}
+
\endlist
\section1 Demos
diff --git a/doc/src/declarative/extending-tutorial.qdoc b/doc/src/declarative/extending-tutorial.qdoc
new file mode 100644
index 0000000000..f00b858098
--- /dev/null
+++ b/doc/src/declarative/extending-tutorial.qdoc
@@ -0,0 +1,420 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+/*!
+
+\page qml-extending-tutorial-index.html
+\title Tutorial: Writing QML extensions with C++
+
+The QtDeclarative module provides a set of APIs for extending QML through
+C++ extensions. You can write extensions to add your own QML types, extend existing
+Qt types, or call C/C++ functions that are not accessible from ordinary QML code.
+
+This tutorial shows how to write a QML extension using C++ that includes
+core QML features, including properties, signals and bindings. It also shows how
+extensions can be deployed through plugins.
+
+You can find the source code for this tutorial in \c Qt's
+examples/declarative/tutorials/extending directory.
+
+Tutorial chapters:
+
+\list 1
+\o \l{declarative/tutorials/extending/chapter1-basics}{Creating a New Type}
+\o \l{declarative/tutorials/extending/chapter2-methods}{Connecting to C++ Methods and Signals}
+\o \l{declarative/tutorials/extending/chapter3-bindings}{Adding Property Bindings}
+\o \l{declarative/tutorials/extending/chapter4-customPropertyTypes}{Using Custom Property Types}
+\o \l{declarative/tutorials/extending/chapter5-plugins}{Writing an Extension Plugin}
+\o \l{qml-extending-tutorial6.html}{In Summary}
+\endlist
+
+*/
+
+/*!
+\title Chapter 1: Creating a New Type
+
+\example declarative/tutorials/extending/chapter1-basics
+
+Let's create a new QML type called "Musician" that has two properties: a name
+and an instrument. We will make it available in a \l {Modules}{module} called "Music", with
+a module version of 1.0.
+We want this \c Musician type to be usable from QML like this:
+
+\code
+ import Music 1.0
+
+ Musician {
+ name: "Reddy the Rocker"
+ instrument: "Guitar"
+ }
+\endcode
+
+To do this, we need a C++ class that encapsulates this \c Musician type and its two
+properties. Since QML relies heavily on Qt's \l{Meta-Object System}{meta object system},
+this new class must:
+
+\list
+\o inherit from QObject
+\o declare its properties using the Q_PROPERTY() macro
+\endlist
+
+Here is our \c Musician class, defined in \c musician.h:
+
+\snippet declarative/tutorials/extending/chapter1-basics/musician.h 0
+
+It defines the two properties, \c name and \c instrument, with the Q_PROPERTY() macro.
+The class implementation in \c musician.cpp simply sets and returns the \c m_name and
+\c m_instrument values as appropriate.
+
+Our QML file, \c app.qml, creates a \c Musician item and display the musician's details
+using a standard QML \l Text item:
+
+\quotefile declarative/tutorials/extending/chapter1-basics/app.qml
+
+We'll also create a C++ application that uses a QDeclarativeView to run and
+display \c app.qml. The application must register the \c Musician type
+using the qmlRegisterType() function, to allow it to be used from QML. If
+you don't register the type, \c app.qml won't be able to create a \c Musician.
+
+Here is the application \c main.cpp:
+
+\snippet declarative/tutorials/extending/chapter1-basics/main.cpp 0
+
+This call to qmlRegisterType() registers the \c Musician type as a type called "Musician", in a module named "Music",
+with a module version of 1.0.
+
+Lastly, we write a \c .pro project file that includes the files and the \c declarative library:
+
+\quotefile declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro
+
+Now we can build and run the application. Try it yourself with the code in Qt's \c examples/tutorials/extending/chapter1-basics directory.
+
+\example declarative/tutorials/extending/chapter1-basics
+
+At the moment, the \c app.qml is run from within a C++ application.
+This may seem odd if you're used to running QML files with the standard \c qml tool.
+Later on, we'll show how to create a plugin so that you can run \c app.qml using the
+\c qml tool instead.
+
+*/
+
+
+/*!
+\title Chapter 2: Connecting to C++ Methods and Signals
+
+\example declarative/tutorials/extending/chapter2-methods
+
+Suppose we want \c Musician to have a "perform" method that prints a message
+to the console and then emits a "performanceEnded" signal.
+Other elements would be able to call \c perform() and receive
+\c performanceEnded() signals like this:
+
+\quotefile declarative/tutorials/extending/chapter2-methods/app.qml
+
+To do this, we add a \c perform() method and a \c performanceEnded() signal
+to our C++ class:
+
+\snippet declarative/tutorials/extending/chapter2-methods/musician.h 0
+\dots
+\snippet declarative/tutorials/extending/chapter2-methods/musician.h 1
+\dots
+\snippet declarative/tutorials/extending/chapter2-methods/musician.h 2
+\dots
+\snippet declarative/tutorials/extending/chapter2-methods/musician.h 3
+
+The use of Q_INVOKABLE makes the \c perform() method available to the
+Qt Meta-Object system, and in turn, to QML. Note that it could have
+been declared as as a Qt slot instead of using Q_INVOKABLE, as
+slots are also callable from QML. Both of these approaches are valid.
+
+The \c perform() method simply prints a message to the console and
+then emits \c performanceEnded():
+
+\snippet declarative/tutorials/extending/chapter2-methods/musician.cpp 0
+
+Now when we run the application and click the window, the application outputs:
+
+\code
+ "Reddy the Rocker" is playing the "Guitar"
+ The performance has now ended
+\endcode
+
+Try out the example yourself with the updated code in Qt's \c examples/tutorials/extending/chapter2-methods directory.
+
+*/
+
+/*!
+\title Chapter 3: Adding Property Bindings
+
+\example declarative/tutorials/extending/chapter3-bindings
+
+Property bindings is a powerful feature of QML that allows values of different
+elements to be synchronized automatically. It uses signals to notify and update
+other elements' values when property values change.
+
+Let's enable property bindings for the \c instrument property. That means
+if we have code like this:
+
+\quotefile declarative/tutorials/extending/chapter3-bindings/app.qml
+
+The "instrument: reddy.instrument" statement binds the \c instrument value of
+\c craig to the \c instrument of \c reddy.
+Whenever \c reddy's \c instrument value changes, \c craig's \c instrument value
+updates to the same value. When the window is clicked, the application outputs:
+
+\code
+ "Reddy the Rocker" is playing the "Guitar"
+ "Craig the Copycat" is playing the "Guitar"
+ "Reddy the Rocker" is playing the "Drums"
+ "Craig the Copycat" is playing the "Drums"
+\endcode
+
+It's easy to enable property binding for the \c instrument property.
+We add a \l{Qt's Property System}{NOTIFY} feature to its Q_PROPERTY() declaration to indicate that a "instrumentChanged" signal
+is emitted whenever the value changes.
+
+\snippet declarative/tutorials/extending/chapter3-bindings/musician.h 0
+\dots
+\snippet declarative/tutorials/extending/chapter3-bindings/musician.h 1
+\dots
+\snippet declarative/tutorials/extending/chapter3-bindings/musician.h 2
+\dots
+\snippet declarative/tutorials/extending/chapter3-bindings/musician.h 3
+
+Then, we emit this signal in \c setInstrument():
+
+\snippet declarative/tutorials/extending/chapter3-bindings/musician.cpp 0
+
+It's important for \c setInstrument() to check that the instrument value has actually changed
+before emitting \c instrumentChanged(). This ensures the signal is not emitted unnecessarily and
+also prevents loops when other elements respond to the value change.
+
+*/
+
+/*!
+\title Chapter 4: Using Custom Property Types
+
+\example declarative/tutorials/extending/chapter4-customPropertyTypes
+
+The \c Musician type currently has two properties that are both strings.
+It could have all sorts of other properties. For example, we could add an
+integer-type property to store the age of each musician:
+
+\code
+ class Musician : public QObject
+ {
+ ...
+ Q_PROPERTY(int age READ age WRITE setAge)
+ public:
+ ...
+ int age() const;
+ void setAge(int age);
+ ...
+ };
+\endcode
+
+We can also use various other property types. QML has built-in support for the following
+types:
+
+\list
+\o bool
+\o unsigned int, int
+\o float, double, qreal
+\o QString
+\o QUrl
+\o QColor
+\o QDate, QTime, QDateTime
+\o QPoint, QPointF
+\o QSize, QSizeF
+\o QRect, QRectF
+\o QVariant
+\endlist
+
+If we want to create a property whose type is not supported by QML by default,
+we need to register the type with QML.
+
+For example, let's change the type of the \c instrument property from a string to a
+new type called "Instrument". Instead of assigning a string value to \c instrument,
+we assign an \c Instrument value:
+
+\quotefile declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml
+
+Like \c Musician, this new \c Instrument type has to inherit from QObject and declare
+its properties with Q_PROPERTY():
+
+\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.h 0
+
+To use it from \c Musician, we modify the \c instrument property declaration
+and associated method signatures:
+
+\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/musician.h 0
+\dots
+\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/musician.h 1
+\dots
+\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/musician.h 2
+\dots
+\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/musician.h 3
+
+Like the \c Musician type, the \c Instrument type has to be registered
+using qmlRegisterType() to be used from QML. As with \c Musician, we'll add the
+type to the "Music" module, version 1.0:
+
+\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp 0
+\dots
+\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp 1
+\dots
+\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp 2
+
+Try it out with the code in Qt's \c examples/tutorials/extending/chapter4-customPropertyTypes directory.
+
+*/
+
+/*!
+\title Chapter 5: Writing an Extension Plugin
+
+\example declarative/tutorials/extending/chapter5-plugins
+
+Currently the \c Musician and \c Instrument types are used by \c app.qml,
+which is displayed using a QDeclarativeView in a C++ application. An alternative
+way to use our QML extension is to create a plugin library to make it available
+to the QML engine. This means we could load \c app.qml using the standard \c qml tool
+(or some other QML runtime application) instead of writing a \c main.cpp file and
+loading our own C++ application.
+
+To create a plugin library, we need:
+
+\list
+\o A plugin class that registers our QML types
+\o A project file that describes the plugin
+\o A "qmldir" file that tells the QML engine to load the plugin
+\endlist
+
+First, we create a plugin class named \c MusicPlugin. It subclasses QDeclarativeExtensionPlugin
+and registers our QML types in the inherited \l{QDeclarativeExtensionPlugin::}{registerTypes()} method. It also calls
+Q_EXPORT_PLUGIN2 for Qt's \l{How to Create Qt Plugins}{plugin system}.
+
+Here is the \c MusicPlugin definition in \c musicplugin.h:
+
+\snippet declarative/tutorials/extending/chapter5-plugins/musicplugin.h 0
+
+And its implementation in \c musicplugin.cpp:
+
+\snippet declarative/tutorials/extending/chapter5-plugins/musicplugin.cpp 0
+
+Then, we write a \c .pro project file that defines the project as a plugin library
+and specifies with DESTDIR that library files should be built into a "lib" subdirectory:
+
+\quotefile declarative/tutorials/extending/chapter5-plugins/chapter5-plugins.pro
+
+Finally, we add a \c qmldir file that is automatically parsed by the QML engine.
+Here, we specify that a plugin named "chapter5-plugin" (the name
+of the example project) can be found in the "lib" subdirectory:
+
+\quotefile declarative/tutorials/extending/chapter5-plugins/qmldir
+
+Now we have a plugin, and instead of having a main.cpp and an executable, we can build
+the project and then run the QML file directly using the \c qml tool:
+
+\code
+ qml app.qml
+\endcode
+
+Notice the "import Music 1.0" statement has disappeared from \c app.qml. This is
+because the \c qmldir file is in the same directory as \c app.qml: this is equivalent to
+having Musician.qml and Instrument.qml files inside the project directory, which could both
+be used by \c app.qml without import statements.
+*/
+
+/*!
+\page qml-extending-tutorial6.html
+\title Chapter 6: In Summary
+
+In this tutorial, we've shown the basic steps for creating a QML extension:
+
+\list
+\o Define new QML types by subclassing QObject and registering them with qmlRegisterType()
+\o Add callable methods using Q_INVOKABLE or Qt slots, and connect to Qt signals with an \c onSignal syntax
+\o Add property bindings by defining \l{Qt's Property System}{NOTIFY} signals
+\o Define custom property types if the built-in types are not sufficient
+\o Create a plugin library by defining a Qt plugin and writing a \c qmldir file
+\endlist
+
+
+The \l {Extending QML in C++} reference documentation shows other useful features that can be added to
+QML extensions. For example, we could use \l{Object and List Property Types}{list properties} to allow multiple instruments for a \c Musician:
+
+\code
+ Musician {
+ instruments: [
+ Instrument { type: "Guitar" }
+ Instrument { type: "Drums" }
+ Instrument { type: "Keyboard" }
+ ]
+ }
+\endcode
+
+Or use \l{Default Property}{default properties} and avoid an
+\c instruments property altogether:
+
+\code
+ Musician {
+ Instrument { type: "Guitar" }
+ Instrument { type: "Drums" }
+ Instrument { type: "Keyboard" }
+ }
+\endcode
+
+Or even change the \c instrument of a \c Musician from time to time using \l{Property Value Sources}{property value sources}:
+
+\code
+ Musician {
+ InstrumentRandomizer on instrument {}
+ }
+\endcode
+
+
+See the \l{Extending QML in C++}{reference documentation} for more information.
+
+Additionally, \l {Integrating QML with existing Qt UI code} shows how to create
+and integrate with QML extensions that have drawing and graphical capabilities (through QGraphicsWidget).
+
+*/
+
diff --git a/doc/src/declarative/extending.qdoc b/doc/src/declarative/extending.qdoc
index c27d091532..1c159e401c 100644
--- a/doc/src/declarative/extending.qdoc
+++ b/doc/src/declarative/extending.qdoc
@@ -43,7 +43,7 @@
\page qml-extending.html
\title Extending QML in C++
-The QML syntax declaratively describes how to construct an in memory object
+The QML syntax declaratively describes how to construct an in-memory object
tree. In Qt, QML is mainly used to describe a visual scene graph, but it is
not conceptually limited to this: the QML format is an abstract description of
any object tree. All the QML element types included in Qt are implemented using
@@ -65,7 +65,7 @@ QML relies heavily on Qt's meta object system and can only instantiate classes
that derive from QObject.
The QML engine has no intrinsic knowledge of any class types. Instead the
-programmer must define the C++ types, and their corresponding QML name.
+programmer must register the C++ types with their corresponding QML names.
Custom C++ types are registered using a template function:
@@ -152,7 +152,7 @@ template<typename T>
int qmlRegisterInterface(const char *typeName)
\endcode
-Registers the C++ interface \a T with the QML system as \a typeName.
+This registers the C++ interface \a T with the QML system as \a typeName.
Following registration, QML can coerce objects that implement this interface
for assignment to appropriately typed properties.
@@ -196,7 +196,7 @@ registered, the following function can be used:
int qmlRegisterType()
\endcode
-Registers the C++ type \a T with the QML system. The parameterless call to the template
+This registers the C++ type \a T with the QML system. The parameterless call to the template
function qmlRegisterType() does not define a mapping between the
C++ class and a QML element name, so the type is not instantiable from QML, but
it is available for type coercion.
@@ -222,7 +222,7 @@ The QML snippet shown above assigns a collection of objects to the
The \e {default property} is a syntactic convenience that allows a type designer to
specify a single property as the type's default. The default property is
assigned to whenever no explicit property is specified. As a convenience, it is
-behaviorally identical to assigning the default property explicitly by name.
+behaviorally identical to assigning to the default property explicitly by name.
From C++, type designers mark the default property using a Q_CLASSINFO()
annotation:
@@ -232,7 +232,7 @@ annotation:
Q_CLASSINFO("DefaultProperty", "property")
\endcode
-Mark \a property as the class's default property. \a property must be either
+This marks \a property as the class's default property. \a property must be either
an object property, or a list property.
A default property is optional. A derived class inherits its base class's
@@ -248,7 +248,7 @@ specify a default property.
\snippet examples/declarative/extending/grouped/example.qml 1
-The QML snippet shown above assigns a number properties to the \c Boy object,
+The QML snippet shown above assigns a number of properties to the \c Boy object,
including four properties using the grouped property syntax.
Grouped properties collect similar properties together into a single named
@@ -273,13 +273,13 @@ implement the \c shoe property grouping.
\snippet examples/declarative/extending/attached/example.qml 1
-The QML snippet shown above assigns the \c rsvp property using the attached
+The QML snippet shown above assigns a date to the \c rsvp property using the attached
property syntax.
Attached properties allow unrelated types to annotate other types with some
additional properties, generally for their own use. Attached properties are
identified through the use of the attacher type name, in the case shown
-\c BirthdayParty, as a suffix to the property name.
+\c BirthdayParty, as a prefix to the property name.
In the example shown, \c BirthdayParty is called the attaching type, and the
\c Boy instance the attachee object instance.
@@ -306,7 +306,7 @@ public:
QML_DECLARE_TYPEINFO(MyType, QML_HAS_ATTACHED_PROPERTIES)
\endcode
-Return an attachment object, of type \a AttachedPropertiesType, for the
+This returns an attachment object, of type \a AttachedPropertiesType, for the
attachee \a object instance. It is customary, though not strictly required, for
the attachment object to be parented to \a object to prevent memory leaks.
@@ -349,7 +349,7 @@ an instance can be accessed using the following method:
template<typename T>
QObject *qmlAttachedPropertiesObject<T>(QObject *attachee, bool create = true);
\endcode
-Returns the attachment object attached to \a attachee by the attaching type
+This returns the attachment object attached to \a attachee by the attaching type
\a T. If type \a T is not a valid attaching type, this method always returns 0.
If \a create is true, a valid attachment object will always be returned,
@@ -366,7 +366,7 @@ It is an element's responsibility to ensure that it does not access or return
pointers to invalid objects. QML makes the following guarentees:
\list
-\o An object assigned to an QObject (or QObject-derived) pointer property will be
+\o An object assigned to a QObject (or QObject-derived) pointer property will be
valid at the time of assignment.
Following assignment, it is the responsibility of the class to subsequently guard
@@ -562,19 +562,22 @@ extension type - when registering the target class whose properties are
transparently merged with the original target class when used from within QML.
An extension class is a regular QObject, with a constructor that takes a QObject
-pointer. When needed (extension classes are delay created until the first extended
+pointer. When needed (extension class creation is delayed until the first extended
property is accessed) the extension class is created and the target object is
passed in as the parent. When an extended property on the original is accessed,
the appropriate property on the extension object is used instead.
When an extended type is installed, one of the
\code
- #define QML_REGISTER_EXTENDED_TYPE(URI, VMAJ, VFROM, VTO, QDeclarativeName,T, ExtendedT)
- #define QML_REGISTER_EXTENDED_NOCREATE_TYPE(T, ExtendedT)
+template<typename T, typename ExtendedT>
+int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
+
+template<typename T, typename ExtendedT>
+int qmlRegisterType()
\endcode
-macros should be used instead of the regular \c QML_REGISTER_TYPE or
-\c QML_REGISTER_NOCREATE_TYPE. The arguments are identical to the corresponding
-non-extension object macro, except for the ExtendedT parameter which is the type
+functions should be used instead of the regular \c qmlRegisterType() variations.
+The arguments are identical to the corresponding non-extension registration functions,
+except for the ExtendedT parameter which is the type
of the extension object.
\section1 Optimization
diff --git a/doc/src/declarative/globalobject.qdoc b/doc/src/declarative/globalobject.qdoc
index 6709ab47df..57eaae7717 100644
--- a/doc/src/declarative/globalobject.qdoc
+++ b/doc/src/declarative/globalobject.qdoc
@@ -223,7 +223,7 @@ of their use.
function finishCreation(){
if(component.isReady()){
sprite = component.createObject();
- if(sprite == 0){
+ if(sprite == null){
// Error Handling
}else{
sprite.parent = page;
@@ -248,7 +248,7 @@ of their use.
\code
component = createComponent("Sprite.qml");
sprite = component.createObject();
- if(sprite == 0){
+ if(sprite == null){
// Error Handling
console.log(component.errorsString());
}else{
diff --git a/doc/src/declarative/integrating.qdoc b/doc/src/declarative/integrating.qdoc
index 65413ec1f3..0051f091bc 100644
--- a/doc/src/declarative/integrating.qdoc
+++ b/doc/src/declarative/integrating.qdoc
@@ -152,8 +152,8 @@ Here is a screenshot of the result:
\image declarative-integrating-graphicswidgets.png
-Note this approach of creating your graphics widgets from QML does not work
-with QGraphicsItem objects that are not QGraphicsWidget-based, since they are not QObjects.
+Note this approach of creating your graphics objects from QML does not work
+with QGraphicsItems that are not QGraphicsObject-based, since they are not QObjects.
See \l{Extending QML in C++} for further information on using C++ types.
diff --git a/doc/src/declarative/javascriptblocks.qdoc b/doc/src/declarative/javascriptblocks.qdoc
index 7c0570e661..2db7e8e7b0 100644
--- a/doc/src/declarative/javascriptblocks.qdoc
+++ b/doc/src/declarative/javascriptblocks.qdoc
@@ -75,7 +75,7 @@ Item {
MouseArea {
anchors.fill: parent
- onClicked: print(factorial(10))
+ onClicked: console.log(factorial(10))
}
}
\endcode
@@ -99,7 +99,7 @@ import "factorial.js" as MathFunctions
Item {
MouseArea {
anchors.fill: parent
- onClicked: print(MathFunctions.factorial(10))
+ onClicked: console.log(MathFunctions.factorial(10))
}
}
\endcode
@@ -184,6 +184,9 @@ Any element in a QML file - including nested elements and nested QML component
instances - can use this attached property. If there is more than one \c onCompleted()
handler to execute at startup, they are run sequentially in an undefined order.
+Likewise, the \l {Component::onDestruction} attached property is triggered on
+component destruction.
+
\section1 QML JavaScript Restrictions
QML executes standard JavaScript code, with the following restrictions:
@@ -204,16 +207,18 @@ is illegal in QML.
\code
// Illegal modification of undeclared variable
a = 1;
-for (var ii = 1; ii < 10; ++ii) a = a * ii;
- console.log("Result: " + a);
+for (var ii = 1; ii < 10; ++ii)
+ a = a * ii;
+console.log("Result: " + a);
\endcode
It can be trivially modified to this legal code.
\code
var a = 1;
-for (var ii = 1; ii < 10; ++ii) a = a * ii;
- console.log("Result: " + a);
+for (var ii = 1; ii < 10; ++ii)
+ a = a * ii;
+console.log("Result: " + a);
\endcode
Any attempt to modify the global object - either implicitly or explicitly - will
diff --git a/doc/src/declarative/measuring-performance.qdoc b/doc/src/declarative/measuring-performance.qdoc
deleted file mode 100644
index cb608bf343..0000000000
--- a/doc/src/declarative/measuring-performance.qdoc
+++ /dev/null
@@ -1,122 +0,0 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
-
-/*!
-\page optimizing-performance.html
-\target optimizing-performance
-\title Optimizing Performance in QML
-
-The Qt Declarative module includes several tools to help measure performance.
-
-\section1 Performance Logging
-
-The declarative module uses the functionality provided by QPerformanceLog to log performance information. To see this information you can add the following to src.pro:
-
-\code
-DEFINES += Q_ENABLE_PERFORMANCE_LOG
-\endcode
-
-The performance information will be printed to screen on a QML application startup, or when running the viewer can be forced at anytime by pressing 'F3' on the keyboard.
-
-Additional logging can be enabled by adding the relevant categories to qfxperf.h and qfxperf.cpp.
-
-For example, to measure the cost of calculating the size of a text item, you would first define a TextSize category by adding the following:
-
-\code
-//in qfxperf.h
-Q_DECLARE_PERFORMANCE_METRIC(TextSize);
-
-//in qfxperf.cpp
-Q_DEFINE_PERFORMANCE_METRIC(TextSize, "Text Size Calculation");
-\endcode
-
-You could then use this category in the code:
-
-\code
-void QDeclarativeText::updateSize()
-{
- QDeclarativePerfTimer<QDeclarativePerf::TextSize> perf;
- ...
-}
-\endcode
-
-Because there is no cost for a QDeclarativePerfTimer when Q_ENABLE_PERFORMANCE_LOG is not defined, this line can persist in the code and be used to help detect performance bottlenecks and regressions. See the QPerformanceLog documentation for more information on this performance framework.
-
-\section1 FPS Measurements
-
-When running the viewer, pressing 'F2' on the keyboard while a QML program is running will cause information on cost-per-frame and frames-per-second (FPS) to be printed to the console.
-
-The information printed includes:
-\list
-\o \e repaint(): the total time spent painting.
-\o \e paint(): the time spent by Qt painting.
-\o \e timeBetweenFrames: the total time spent per frame. This number minus repaint() gives a good idea of how much time is spent on things besides painting. A high number here with a low number for repaint() indicates expensive calculations happening each frame.
-\endlist
-
-\section1 Improving Performance
-
-The following tips can help decrease startup time for QML-based appications.
-
-\section2 Images
-
-\list
-\o Use jpg instead of png for photo-like images. On the N810, this can save 150ms for a large (320x480) image.
-
-\o If you are configuring Qt, configure out any image plugins you don't plan to support (mng and svg are the most expensive). On the N810, this can save 75-100ms startup time. For example:
-
-\code
-configure -no-libmng -no-svg -no-libtiff
-\endcode
-
-\o In some cases running pngcrush, optipng, gifsicle or other similar tools can give some improvement.
-
-We are also investigating support for the loading of uncompressed images. This will provide opportunites to decrease startup time at the cost of increased storage space.
-\endlist
-
-\section2 Fonts
-
-\list
-\o Use qpf instead of ttf. When using multiple font sizes and weights on the N810, this can save 125ms startup time compared to a ttf 'clean' run, and 40-50ms on subsequent runs (ttfs are shared by open applications).
-\endlist
-
-*/
-
-*/
diff --git a/doc/src/declarative/network.qdoc b/doc/src/declarative/network.qdoc
index d268a1357c..68768c6675 100644
--- a/doc/src/declarative/network.qdoc
+++ b/doc/src/declarative/network.qdoc
@@ -130,11 +130,12 @@ See the \tt demos/declarative/flickr for a real demonstration of this.
\section1 Configuring the Network Access Manager
All network access from QML is managed by a QNetworkAccessManager set on the QDeclarativeEngine which executes the QML.
-By default, this is an unmodified Qt QNetworkAccessManager. You may set a different manager using
-QDeclarativeEngine::setNetworkAccessManager() as appropriate for the policies of your application.
-For example, the \l {Qt Declarative UI Runtime}{qml} tool sets a new QNetworkAccessManager which
-trusts HTTP Expiry headers to avoid network cache checks, allows HTTP Pipelining, adds a persistent HTTP CookieJar,
-a simple disk cache, and supports proxy settings.
+By default, this is an unmodified Qt QNetworkAccessManager. You may set a different manager by
+providing a QDeclarativeNetworkAccessManagerFactory and setting it via
+QDeclarativeEngine::setNetworkAccessManagerFactory().
+For example, the \l {Qt Declarative UI Runtime}{qml} tool sets a QDeclarativeNetworkAccessManagerFactory which
+creates QNetworkAccessManager that trusts HTTP Expiry headers to avoid network cache checks,
+allows HTTP Pipelining, adds a persistent HTTP CookieJar, a simple disk cache, and supports proxy settings.
\section1 QRC Resources
diff --git a/doc/src/declarative/qdeclarativedocument.qdoc b/doc/src/declarative/qdeclarativedocument.qdoc
index cf3aae2749..bc099ced80 100644
--- a/doc/src/declarative/qdeclarativedocument.qdoc
+++ b/doc/src/declarative/qdeclarativedocument.qdoc
@@ -93,7 +93,7 @@ behaviour. As it is a template, a single QML component can be "run" multiple ti
produce several objects, each of which are said to be \e instances of the component.
Once created, instances are not dependent on the component that created them, so they can
-operate on independent data. Here is an example of a simple "button" component that is
+operate on independent data. Here is an example of a simple "Button" component that is
instantiated four times, each with a different value for its \c text property.
\table
diff --git a/doc/src/declarative/qdeclarativei18n.qdoc b/doc/src/declarative/qdeclarativei18n.qdoc
index 0a48dd9fbf..c7dbd4d8f4 100644
--- a/doc/src/declarative/qdeclarativei18n.qdoc
+++ b/doc/src/declarative/qdeclarativei18n.qdoc
@@ -86,7 +86,7 @@ lupdate hello.qml -ts hello.ts
\endcode
Then we open \c hello.ts in \l{Qt Linguist Manual} {Linguist}, provide
-a translation and create the release file \c hello.qml.
+a translation and create the release file \c hello.qm.
Finally, we can test the translation:
\code
diff --git a/doc/src/declarative/qdeclarativeintro.qdoc b/doc/src/declarative/qdeclarativeintro.qdoc
index 4d05a8ce8b..a98c9e17cb 100644
--- a/doc/src/declarative/qdeclarativeintro.qdoc
+++ b/doc/src/declarative/qdeclarativeintro.qdoc
@@ -142,8 +142,8 @@ Commenting in QML is similar to JavaScript.
\quotefile doc/src/snippets/declarative/comments.qml
-Comments are ignored by the engine. The are useful for explaining what you
-are doing: for referring back to at a later date, or for others reading
+Comments are ignored by the engine. They are useful for explaining what you
+are doing; for referring back to at a later date, or for others reading
your QML files.
Comments can also be used to prevent the execution of code, which is
diff --git a/doc/src/declarative/qdeclarativestates.qdoc b/doc/src/declarative/qdeclarativestates.qdoc
index 0fea6f8cfa..fd0c677728 100644
--- a/doc/src/declarative/qdeclarativestates.qdoc
+++ b/doc/src/declarative/qdeclarativestates.qdoc
@@ -70,7 +70,7 @@ In QML:
\o A state can affect the properties of other objects, not just the object owning the state (and not just that object's children).
\endlist
-Here is an example of using states. In the default state \c myRect is positioned at 0,0. In the 'moved' state it is positioned at 50,50. Clicking within the mouse region changes the state from the default state to the 'moved' state, thus moving the rectangle.
+Here is an example of using states. In the default state \c myRect is positioned at 0,0. In the 'moved' state it is positioned at 50,50. Clicking within the mouse area changes the state from the default state to the 'moved' state, thus moving the rectangle.
\qml
Item {
diff --git a/doc/src/declarative/qmlruntime.qdoc b/doc/src/declarative/qmlruntime.qdoc
index 9f7183acbf..a724c7d1e0 100644
--- a/doc/src/declarative/qmlruntime.qdoc
+++ b/doc/src/declarative/qmlruntime.qdoc
@@ -52,7 +52,7 @@
QML is a runtime, as you can run plain qml files which pull in their required modules.
To run apps with the QML runtime, you can either start the runtime
- from your on application (using a QDeclarativeView) or with the simple \c qml application.
+ from your own application (using a QDeclarativeView) or with the simple \c qml application.
The \c qml application can be
installed in a production environment, assuming that it is not already
present in the system. It is generally packaged alongside Qt.
@@ -137,8 +137,8 @@
\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.
+ property on the root context. This property contains several pieces of
+ information about the runtime environment of the application.
\section3 Screen Orientation
@@ -150,11 +150,11 @@
which can be either Orientation.Landscape or Orientation.Portrait and which can be bound to in your
application. An example is below:
-\code
+ \code
Item {
state: (runtime.orientation == Orientation.Landscape) ? 'landscape' : ''
}
-\endcode
+ \endcode
This allows your application to respond to the orientation of the screen changing. The runtime
will automatically update this on some platforms (currently the N900 only) to match the physical
@@ -163,12 +163,12 @@
\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,
+ or not. This is especially useful for embedded devices when you want to pause parts of your application,
including animations, when your application loses focus or goes to the background.
The example below, stops the animation when the application's window is deactivated and resumes on activation:
-\code
+ \code
Item {
width: 300; height: 200
Rectangle {
@@ -182,6 +182,6 @@
}
}
}
-\endcode
+ \endcode
*/
diff --git a/doc/src/declarative/qtprogrammers.qdoc b/doc/src/declarative/qtprogrammers.qdoc
index 05ffeb0879..0b408408e4 100644
--- a/doc/src/declarative/qtprogrammers.qdoc
+++ b/doc/src/declarative/qtprogrammers.qdoc
@@ -62,7 +62,7 @@ QML provides direct access to the following concepts from Qt:
\o QObject signals and slots - available as functions to call in JavaScript
\o QObject properties - available as variables in JavaScript
\o QWidget - QDeclarativeView is a QML-displaying widget
- \o Qt models - used directly in data binding (QAbstractItemModel and next generation QListModelInterface)
+ \o Qt models - used directly in data binding (QAbstractItemModel)
\endlist
Qt knowledge is \e required for \l {Extending QML in C++}, and also for \l{Integrating QML with existing Qt UI code}.
@@ -104,7 +104,7 @@ and exactly how it respond to mouse, key, or touch input, should all be left for
in QML.
It is illustrative to note that QDeclarativeTextEdit is built upon QTextControl,
-QDeclarativeWebView is built upon QWebPage, and ListView uses QListModelInterface,
+QDeclarativeWebView is built upon QWebPage, and ListView uses QAbstractItemModel,
just as QTextEdit, QWebView, and QListView are built upon
those same UI-agnostic components.
diff --git a/doc/src/declarative/snippets/qtbinding/contextproperties/main.cpp b/doc/src/declarative/snippets/qtbinding/contextproperties/main.cpp
index 15e3d4cbb4..4073a6cc20 100644
--- a/doc/src/declarative/snippets/qtbinding/contextproperties/main.cpp
+++ b/doc/src/declarative/snippets/qtbinding/contextproperties/main.cpp
@@ -56,7 +56,7 @@ int main(int argc, char *argv[])
context->setContextProperty("backgroundColor",
QColor(Qt::yellow));
- view.setSource(QUrl("main.qml"));
+ view.setSource(QUrl::fromLocalFile("main.qml"));
view.show();
return app.exec();
diff --git a/doc/src/declarative/snippets/qtbinding/custompalette/main.cpp b/doc/src/declarative/snippets/qtbinding/custompalette/main.cpp
index c7236885bd..dc651f6d68 100644
--- a/doc/src/declarative/snippets/qtbinding/custompalette/main.cpp
+++ b/doc/src/declarative/snippets/qtbinding/custompalette/main.cpp
@@ -53,7 +53,7 @@ int main(int argc, char *argv[])
QDeclarativeView view;
view.rootContext()->setContextProperty("palette", new CustomPalette);
- view.setSource(QUrl("main.qml"));
+ view.setSource(QUrl::fromLocalFile("main.qml"));
view.show();
return app.exec();
diff --git a/doc/src/declarative/snippets/qtbinding/stopwatch/main.cpp b/doc/src/declarative/snippets/qtbinding/stopwatch/main.cpp
index 13e3b9f255..537a2888ff 100644
--- a/doc/src/declarative/snippets/qtbinding/stopwatch/main.cpp
+++ b/doc/src/declarative/snippets/qtbinding/stopwatch/main.cpp
@@ -54,7 +54,7 @@ int main(int argc, char *argv[])
view.rootContext()->setContextProperty("stopwatch",
new Stopwatch);
- view.setSource(QUrl("main.qml"));
+ view.setSource(QUrl::fromLocalFile("main.qml"));
view.show();
return app.exec();
diff --git a/doc/src/examples/dragdroprobot.qdoc b/doc/src/examples/dragdroprobot.qdoc
index 413f190170..887b254600 100644
--- a/doc/src/examples/dragdroprobot.qdoc
+++ b/doc/src/examples/dragdroprobot.qdoc
@@ -43,9 +43,337 @@
\example graphicsview/dragdroprobot
\title Drag and Drop Robot Example
- This GraphicsView example shows how to implement drag and drop in
- a QGraphicsItem subclass, as well as how to animate items using
- QGraphicsItemAnimation and QTimeLine.
+ This GraphicsView example shows how to implement Drag and Drop in a
+ QGraphicsItem subclass, as well as how to animate items using Qt's
+ \l{Animation Framework}.
\image dragdroprobot-example.png
+
+ Graphics View provides the QGraphicsScene class for managing and
+ interacting with a large number of custom-made 2D graphical items derived
+ from the QGraphicsItem class, and a QGraphicsView widget for visualizing
+ the items, with support for zooming and rotation.
+
+ This example consists of a \c Robot class, a \c ColorItem class, and a main
+ function: the \c Robot class describes a simple robot consisting of several
+ \c RobotPart derived limbs, including \c RobotHead and \c RobotLimb, the \c
+ ColorItem class provides a draggable colored ellipse, and the \c main()
+ function provides the main application window.
+
+ We will first review the \c Robot class to see how to assemble the
+ different parts so that they can be individually rotated and animated using
+ QPropertyAnimation, and we will then review the \c ColorItem class to
+ demonstrate how to implement Drag and Drop between items. Finally we will
+ review the main() function to see how we can put all the pieces together,
+ to form the final application.
+
+ \section1 Robot Class Definition
+
+ The robot consists of three main classes: the \c RobotHead, the \c
+ RobotTorso, and the \c RobotLimb, which is used for the upper and lower
+ arms and legs. All parts derive from the \c RobotPart class, which in turn
+ inherits \c QGraphicsObject. The \c Robot class itself has no visual
+ appearance and serves only as a root node for the robot.
+
+ Let's start with the \c RobotPart class declaration.
+
+ \snippet examples/graphicsview/dragdroprobot/robot.h 0
+
+ This base class inherits QGraphicsObject. QGraphicsObject provides signals
+ and slots through inheriting QObject, and it also declares QGraphicsItem's
+ properties using Q_PROPERTY, which makes the properties accessible for
+ QPropertyAnimation.
+
+ RobotPart also implements the three most important event handlers for
+ accepting drop events:
+ \l{QGraphicsItem::dragEnterEvent()}{dragEnterEvent()},
+ \l{QGraphicsItem::dragLeaveEvent()}{dragLeaveEvent()}, and
+ \l{QGraphicsItem::dropEvent()}{dropEvent()}.
+
+ The color is stored as a member variable, along with the \c dragOver
+ variable, which we will use later to indicate visually that the limb can
+ accept colors that are is dragged onto it.
+
+ \snippet examples/graphicsview/dragdroprobot/robot.cpp 0
+
+ \c RobotPart's constructor initializes the dragOver member and sets the
+ color to Qt::lightGray. In the constructor body we enable support for
+ accepting drop events by calling
+ \l{QGraphicsItem::setAcceptDrops()}{setAcceptDrops(true)}.
+
+ The rest of this class's implementation is to support Drag and Drop.
+
+ \snippet examples/graphicsview/dragdroprobot/robot.cpp 1
+
+ The \l{QGraphicsItem::dragEnterEvent()}{dragEnterEvent()} handler is called
+ when a Drag and Drop element is dragged into the robot part's area.
+
+ The handler implementation determines whether or not this item as a whole
+ can accept the mime data assiciated with the incoming drag object. \c
+ RobotPart provides a base behavior for all parts that accepts color drops.
+ So if the incoming drag object contains a color, the event is accepted, we
+ set \c dragOver to \c true and call update() to help provide positive
+ visual feedback to the user; otherwise the event is ignored, which in turn
+ allows the event to propagate to parent elements.
+
+ \snippet examples/graphicsview/dragdroprobot/robot.cpp 2
+
+ The \l{QGraphicsItem::dragLeaveEvent()}{dragLeaveEvent()} handler is called
+ when a Drag and Drop element is dragged away from the robot part's area.
+ Our implementation simply resets \e dragOver to false and calls
+ \l{QGraphicsItem::update()}{update()} to help provide visual feedback that
+ the drag has left this item.
+
+ \snippet examples/graphicsview/dragdroprobot/robot.cpp 3
+
+ The \l{QGraphicsItem::dropEvent()}{dropEvent()} handler is called when a
+ Drag and Drop element is dropped onto an item (i.e., when the mouse button
+ is released over the item while dragging).
+
+ We reset \c dragOver to false, assign the item's new color, and call
+ \l{QGraphicsItem::update()}{update()}.
+
+ The declaration and implementation of \c RobotHead, \c RobotTorso, and \c
+ RobotLimb are practically identical. We will review \c RobotHead in detail,
+ as this class has one minor difference, and leave the other classes as an
+ exercise for the reader.
+
+ \snippet examples/graphicsview/dragdroprobot/robot.h 1
+
+ The \c RobotHead class inherits \c RobotPart and provides the necessary
+ implementations of \l{QGraphicsItem::boundingRect()}{boundingRect()} and
+ \l{QGraphicsItem::paint()}{paint()}. It also reimplements
+ \l{QGraphicsItem::dragEnterEvent()}{dragEnterEvent()} and dropEvent() to
+ provide special handling of image drops.
+
+ The class contains a private pixmap member that we can use to implement
+ support for accepting image drops.
+
+ \snippet examples/graphicsview/dragdroprobot/robot.cpp 4
+
+ \c RobotHead has a rather plain constructor that simply forwards to
+ \c RobotPart's constructor.
+
+ \snippet examples/graphicsview/dragdroprobot/robot.cpp 5
+
+ The \l{QGraphicsItem::boundingRect()}{boundingRect()} reimplementation
+ returns the extents for the head. Because we want the center of rotation to
+ be the bottom center of the item, we have chosen a bounding rectangle that
+ starts at (-15, -50) and extends to 30 units wide and 50 units tall. When
+ rotating the head, the "neck" will stay still while the top of the head
+ tilts from side to side.
+
+ \snippet examples/graphicsview/dragdroprobot/robot.cpp 6
+
+ In \l{QGraphicsItem::paint()}{paint()} we draw the actual head. The
+ implementation is split into two sections; if an image has been dropped
+ onto the head, we draw the image, otherwise we draw a round rectangular
+ robot head with simple vector graphics.
+
+ For performance reasons, depending on the complexity of what is painted, it
+ can often be faster to draw the head as an image rather than using a
+ sequence of vector operations.
+
+ \snippet examples/graphicsview/dragdroprobot/robot.cpp 7
+
+ The robot head can accept image drops. In order to support this, its
+ reimplementation of \l{QGraphicsItem::dragEnterEvent()}{dragEnterEvent()}
+ checks if the drag object contains image data, and if it does, then the
+ event is accepted. Otherwise we fall back to the base \c RobotPart
+ implementation.
+
+ \snippet examples/graphicsview/dragdroprobot/robot.cpp 8
+
+ To follow up on image support, we must also implement
+ \l{QGraphicsItem::dropEvent()}{dropEvent()}. We check if the drag object
+ contains image data, and if it does, we store this data as a member pixmap
+ and call \l{QGraphicsItem::update()}{update()}. This pixmap is used inside
+ the \l{QGraphicsItem::paint()}{paint()} implementation that we reviewed
+ before.
+
+ \c RobotTorso and \c RobotLimb are similar to \c RobotHead, so let's
+ skip directly to the \c Robot class.
+
+ \snippet examples/graphicsview/dragdroprobot/robot.h 4
+
+ The \c Robot class also inherits \c RobotPart, and like the other parts it
+ also implements \l{QGraphicsItem::boundingRect()}{boundingRect()} and
+ \l{QGraphicsItem::paint()}{paint()}. It provides a rather special
+ implementation, though:
+
+ \snippet examples/graphicsview/dragdroprobot/robot.cpp 9
+
+ Because the \c Robot class is only used as a base node for the rest of the
+ robot, it has no visual representation. Its
+ \l{QGraphicsItem::boundingRect()}{boundingRect()} implementation can
+ therefore return a null QRectF, and its paint() function does nothing.
+
+ \snippet examples/graphicsview/dragdroprobot/robot.cpp 10
+
+ The constuctor starts by setting the flag
+ \l{QGraphicsItem::ItemHasNoContents}{ItemHasNoContents}, which is a minor
+ optimization for items that have no visual appearance.
+
+ We then construct all the robot parts (head, torso, and upper/lower arms
+ and legs). The stacking order is very important, and we use the
+ parent-child hierarchy to ensure the elements rotate and move properly. We
+ construct the torso first, as this is the root element. We then construct
+ the head and pass the torso to \c HeadItem's constructor. This will make
+ the head a child of the torso; if you rotate the torso, the head will
+ follow. The same pattern is applied to the rest of the limbs.
+
+ \snippet examples/graphicsview/dragdroprobot/robot.cpp 11
+
+ Each robot part is carefully positioned. For example, the upper left arm is
+ moved precisely to the top-left area of the torso, and the upper right arm
+ is moved to the top-right area.
+
+ \snippet examples/graphicsview/dragdroprobot/robot.cpp 12
+
+ The next section creates all animation objects. This snippet shows the two
+ animations that operate on the head's scale and rotation. The two
+ QPropertyAnimation instances simply set the object, property, and
+ respective start and end values.
+
+ All animations are controlled by one top-level parallel animation group.
+ The scale and rotation animations are added to this group.
+
+ The rest of the animations are defined in a similar way.
+
+ \snippet examples/graphicsview/dragdroprobot/robot.cpp 13
+
+ Finally we set an easing curve and duration on each animation, ensure the
+ toplevel animation group loops forever, and start the toplevel animation.
+
+ \section1 ColorItem Class Definition
+
+ The \c ColorItem class represents a circular item that can be pressed to
+ drag colors onto robot parts.
+
+ \snippet examples/graphicsview/dragdroprobot/coloritem.h 0
+
+ This class is very simple. It does not use animations, and has no need for
+ properties nor signals and slots, so to save resources, it's most natural
+ that it inherits QGraphicsItem (as opposed to QGraphicsObject).
+
+ It declares the mandatory \l{QGraphicsItem::boundingRect()}{boundingRect()}
+ and \l{QGraphicsItem::paint()}{paint()} functions, and adds
+ reimplementations of
+ \l{QGraphicsItem::mousePressEvent()}{mousePressEvent()},
+ \l{QGraphicsItem::mouseMoveEvent()}{mouseMoveEvent()}, and
+ \l{QGraphicsItem::mouseReleaseEvent()}{mouseReleaseEvent()}. It contains a
+ single private color member.
+
+ Let's take a look at its implementation.
+
+ \snippet examples/graphicsview/dragdroprobot/coloritem.cpp 0
+
+ \c ColorItem's constructor assigns an opaque random color to its color
+ member by making use of qrand(). For improved usability, it assigns a
+ tooltip that provides a useful hint to the user, and it also sets a
+ suitable cursor. This ensures that the cursor will chance to
+ Qt::OpenHandCursor when the mouse pointer hovers over the item.
+
+ Finally, we call
+ \l{QGraphicsItem::setAcceptedMouseButtons()}{setAcceptedMouseButtons()} to
+ ensure that this item can only process Qt::LeftButton. This simplifies the
+ mouse event handlers greatly, as we can always assume that only the left
+ mouse button is pressed and released.
+
+ \snippet examples/graphicsview/dragdroprobot/coloritem.cpp 1
+
+ The item's bounding rect is a fixed 30x30 units centered around the item's
+ origin (0, 0), and adjusted by 0.5 units in all directions to allow a
+ scalable pen to draw its outline. For a final visual touch the bounds
+ also compensate with a few units down and to the right to make room
+ for a simple dropshadow.
+
+ \snippet examples/graphicsview/dragdroprobot/coloritem.cpp 2
+
+ The \l{QGraphicsItem::paint()}{paint()} implementation draws an ellipse
+ with a 1-unit black outline, a plain color fill, and a dark gray
+ dropshadow.
+
+ \snippet examples/graphicsview/dragdroprobot/coloritem.cpp 3
+
+ The \l{QGraphicsItem::mousePressEvent()}{mousePressEvent()} handler is
+ called when you press the mouse button inside the item's area. Our
+ implementation simply sets the cursor to Qt::ClosedHandCursor.
+
+ \snippet examples/graphicsview/dragdroprobot/coloritem.cpp 4
+
+ The \l{QGraphicsItem::mouseReleaseEvent()}{mouseReleaseEvent()} handler is
+ called when you release the mouse button after having pressed it inside an
+ item's area. Our implementation sets the cursor back to Qt::OpenHandCursor.
+ The mouse press and release event handlers together provide useful visual
+ feedback to the user: when you move the mouse pointer over a \c CircleItem,
+ the cursor changes to an open hand. Pressing the item will show a closed
+ hand cursor. Releasing will restore to an open hand cursor again.
+
+ \snippet examples/graphicsview/dragdroprobot/coloritem.cpp 5
+
+ The \l{QGraphicsItem::mouseMoveEvent()}{mouseMoveEvent()} handler is called
+ when you move the mouse around after pressing the mouse button inside the
+ \c ColorItem's area. This implementation provides the most important piece
+ of logic for \c CircleItem: the code that starts and manages drags.
+
+ The implementation starts by checking if the mouse has been dragged far
+ enough to eliminate mouse jitter noise. We only want to start a drag if the
+ mouse has been dragged farther than the application start drag distance.
+
+ Continuing, we create a QDrag object, passing the event
+ \l{QGraphicsSceneEvent::widget()}{widget} (i.e., the QGraphicsView
+ viewport) to its constructor. Qt will ensure that this object is deleted at
+ the right time. We also create a QMimeData instance that can contain our
+ color or image data, and assign this to the drag object.
+
+ \snippet examples/graphicsview/dragdroprobot/coloritem.cpp 6
+
+ This snippet has a somewhat random outcome: once in a while, a special
+ image is assigned to the drag object's mime data. The pixmap is also
+ assiged as the drag object's pixmap. This will ensure that you can see the
+ image that is being dragged as a pixmap under the mouse cursor.
+
+ \snippet examples/graphicsview/dragdroprobot/coloritem.cpp 7
+
+ Otherwise, and this is the most common outcome, a simple color is assigned
+ to the drag object's mime data. We render this \c ColorItem into a new
+ pixmap to give the user visual feedback that the color is being "dragged".
+
+ \snippet examples/graphicsview/dragdroprobot/coloritem.cpp 8
+
+ Finally we execute the drag. QDrag::exec() will reenter the event loop, and
+ only exit if the drag has either been dropped, or canceled. In any case we
+ reset the cursor to Qt::OpenHandCursor.
+
+ \section1 The main() Function
+
+ Now that the \c Robot and \c ColorItem classes are complete, we can put all
+ the pieces together inside the main() function.
+
+ \snippet examples/graphicsview/dragdroprobot/main.cpp 0
+
+ We start off by constructing QApplication, and initializing the random
+ number generator. This ensures that the color items have different colors
+ every time the application starts.
+
+ \snippet examples/graphicsview/dragdroprobot/main.cpp 1
+
+ We construct a fixed size scene, and create 10 \c ColorItem instances
+ arranged in a circle. Each item is added to the scene.
+
+ In the center of this circle we create one \c Robot instance. The
+ robot is scaled and moved up a few units. It is then added to the scene.
+
+ \snippet examples/graphicsview/dragdroprobot/main.cpp 2
+
+ Finally we create a QGraphicsView window, and assign the scene to it.
+
+ For increased visual quality, we enable antialiasing. We also choose to use
+ bounding rectangle updates to simplify visual update handling.
+ The view is given a fixed sand-colored background, and a window title.
+
+ We then show the view. The animations start immediately after
+ control enters the event loop.
*/
+
diff --git a/doc/src/examples/elasticnodes.qdoc b/doc/src/examples/elasticnodes.qdoc
index f7b1c37f52..edc62d85c0 100644
--- a/doc/src/examples/elasticnodes.qdoc
+++ b/doc/src/examples/elasticnodes.qdoc
@@ -43,7 +43,396 @@
\example graphicsview/elasticnodes
\title Elastic Nodes Example
- This GraphicsView example shows how to implement edges between nodes in a graph.
+ This GraphicsView example shows how to implement edges between nodes in a
+ graph, with basic interaction. You can click to drag a node around, and
+ zoom in and out using the mouse wheel or the keyboard. Hitting the space
+ bar will randomize the nodes. The example is also resolution independent;
+ as you zoom in, the graphics remain crisp.
\image elasticnodes-example.png
+
+ Graphics View provides the QGraphicsScene class for managing and
+ interacting with a large number of custom-made 2D graphical items derived
+ from the QGraphicsItem class, and a QGraphicsView widget for visualizing
+ the items, with support for zooming and rotation.
+
+ This example consists of a \c Node class, an \c Edge class, a \c
+ GraphWidget test, and a \c main function: the \c Node class represents
+ draggable yellow nodes in a grid, the \c Edge class represents the lines
+ between the nodes, the \c GraphWidget class represents the application
+ window, and the \c main() function creates and shows this window, and runs
+ the event loop.
+
+ \section1 Node Class Definition
+
+ The \c Node class serves three purposes:
+
+ \list
+ \o Painting a yellow gradient "ball" in two states: sunken and raised.
+ \o Managing connections to other nodes.
+ \o Calculating forces pulling and pushing the nodes in the grid.
+ \endlist
+
+ Let's start by looking at the \c Node class declaration.
+
+ \snippet examples/graphicsview/elasticnodes/node.h 0
+
+ The \c Node class inherits QGraphicsItem, and reimplements the two
+ mandatory functions \l{QGraphicsItem::boundingRect()}{boundingRect()} and
+ \l{QGraphicsItem::paint()}{paint()} to provide its visual appearance. It
+ also reimplements \l{QGraphicsItem::shape()}{shape()} to ensure its hit
+ area has an elliptic shape (as opposed to the default bounding rectangle).
+
+ For edge management purposes the node provides a simple API for adding
+ edges to a node, and for listing all connected edges.
+
+ The \l{QGraphicsItem::advance()}{advance()} reimplementation is called
+ whenever the scene's state advances by one step. The calculateForces()
+ function is called to calculate the forces that push and pull on this node
+ and its neighbors.
+
+ The \c Node class also reimplements
+ \l{QGraphicsItem::itemChange()}{itemChange()} to react to state changes (in
+ this case, position changes), and
+ \l{QGraphicsItem::mousePressEvent()}{mousePressEvent()} and
+ \l{QGraphicsItem::mouseReleaseEvent()}{mouseReleaseEvent()} to update the
+ item's visual appearance.
+
+ We will start reviewing the \c Node implementation by looking at its
+ constructor:
+
+ \snippet examples/graphicsview/elasticnodes/node.cpp 0
+
+ In the constructor, we set the
+ \l{QGraphicsItem::ItemIsMovable}{ItemIsMovable} flag to allow the item to
+ move in response to mouse dragging, and
+ \l{QGraphicsItem::ItemSendsGeometryChanges}{ItemSendsGeometryChanges} to
+ enable \l{QGraphicsItem::itemChange()}{itemChange()} notifications for
+ position and transformation changes. We also enable
+ \l{QGraphicsItem::DeviceCoordinateCache}{DeviceCoordinateCache} to speed up
+ rendering performance. To ensure that the nodes are always stacked on top
+ of edges, we finally set the item's Z value to -1.
+
+ \c Node's constructor takes a \c GraphWidget pointer and stores this as a
+ member variable. We will revisit this pointer later on.
+
+ \snippet examples/graphicsview/elasticnodes/node.cpp 1
+
+ The addEdge() function adds the input edge to a list of attached edges. The
+ edge is then adjusted so that the end points for the edge match the
+ positions of the source and destination nodes.
+
+ The edges() function simply returns the list of attached edges.
+
+ \snippet examples/graphicsview/elasticnodes/node.cpp 2
+
+ The \e calculateForces() function implements the elastic forces effect that
+ pulls and pushes on nodes in the grid. In addition to this algorithm, the
+ user can move one node around with the mouse. Because we do not want the
+ two to interfere, we start by checking if this \c Node is the current mouse
+ grabber item (i.e., QGraphicsScene::mouseGrabberItem()). Because we need to
+ find all neighboring (but not necessarily connected) nodes, we also make
+ sure the item is part of a scene in the first place.
+
+ \snippet examples/graphicsview/elasticnodes/node.cpp 3
+
+ The algorithm has two steps: the first is to calculate the forces that push
+ the nodes apart, and the second is to subtract the forces that pull the
+ nodes together. First we need to find all the nodes in the graph. We call
+ QGraphicsScene::items() to find all items in the scene, and then use
+ qgraphicsitem_cast() to look for \c Node instances.
+
+ We make use of \l{QGraphicsItem::mapFromItem()}{mapFromItem()} to create a
+ vector pointing from this node to each other node, in \l{The Graphics View
+ Coordinate System}{local coordinates}. We use the decomposed components of
+ this vector to determine the direction and strength of force that apply to
+ the node. The forces are added up for each node, and weighted so that the
+ closest nodes are given the strongest force. The sum of all forces are
+ stored in \e xvel (X-velocity) and \e yvel (Y-velocity).
+
+ \snippet examples/graphicsview/elasticnodes/node.cpp 4
+
+ The edges between the nodes represent the forces that pull the nodes
+ together. By visiting each edge that is connected to this node, we can use
+ a similar approach as above to find the direction and strength of all
+ forces. These forces are subtracted from \e xvel and \e yvel.
+
+ \snippet examples/graphicsview/elasticnodes/node.cpp 5
+
+ In theory, the sum of pushing and pulling forces should stabilize to
+ precisely 0. In practise, however, they never do. To circumvent errors in
+ numerical precision, we simply force the sum of forces to be 0 when they
+ are less than 0.1.
+
+ \snippet examples/graphicsview/elasticnodes/node.cpp 6
+
+ The final step of \e calculateForces() determines the node's new position.
+ We add the force to the node's current position. We also make sure the new
+ position stays inside of our defined boundaries. We don't actually move the
+ item in this function; that's done in a separate step, from \e advance().
+
+ \snippet examples/graphicsview/elasticnodes/node.cpp 7
+
+ The \e advance() function updates the item's current position. It is called
+ from \e GraphWidget::timerEvent(). If the node's position changed, the
+ function returns true; otherwise false is returned.
+
+ \snippet examples/graphicsview/elasticnodes/node.cpp 8
+
+ The \e Node's bounding rectangle is a 20x20 sized rectangle centered around
+ its origin (0, 0), adjusted by 2 units in all directions to compensate for
+ the node's outline stroke, and by 3 units down and to the right to make
+ room for a simple drop shadow.
+
+ \snippet examples/graphicsview/elasticnodes/node.cpp 9
+
+ The shape is a simple ellipse. This ensures that you must click inside the
+ node's elliptic shape in order to drag it around. You can test this effect
+ by running the example, and zooming far enough in so that the nodes become
+ very large. Without reimplementing \l{QGraphicsItem::shape()}{shape()}, the
+ item's hit area would be identical to its bounding rectangle (i.e.,
+ rectangular).
+
+ \snippet examples/graphicsview/elasticnodes/node.cpp 10
+
+ This function implements the node's painting. We start by drawing a simple
+ dark gray elliptic drop shadow at (-7, -7), that is, (3, 3) units down and
+ to the right.
+
+ We then draw an ellipse with a radial gradient fill. This fill is either
+ Qt::yellow to Qt::darkYellow when raised, or the opposite when sunken. In
+ sunken state we also shift the center and focal point by (3, 3) to
+ emphasize the impression that something has been pushed down.
+
+ Drawing filled ellipses with gradients can be quite slow, especially when
+ using complex gradients such as QRadialGradient. This is why this example
+ uses \l{QGraphicsItem::DeviceCoordinateCache}{DeviceCoordinateCache}, a
+ simple yet effective measure that prevents unnecessary redrawing.
+
+ \snippet examples/graphicsview/elasticnodes/node.cpp 11
+
+ We reimplement \l{QGraphicsItem::itemChange()}{itemChange()} to adjust the
+ position of all connected edges, and to notify the scene that an item has
+ moved (i.e., "something has happened"). This will trigger new force
+ calculations.
+
+ This notification is the only reason why the nodes need to keep a pointer
+ back to the \e GraphWidget. Another approach could be to provide such
+ notification using a signal; in such case, \e Node would need to inherit
+ from QGraphicsObject.
+
+ \snippet examples/graphicsview/elasticnodes/node.cpp 12
+
+ Because we have set the \l{QGraphicsItem::ItemIsMovable}{ItemIsMovable}
+ flag, we don't need to implement the logic that moves the node according to
+ mouse input; this is already provided for us. We still need to reimplement
+ the mouse press and release handlers though, to update the nodes' visual
+ appearance (i.e., sunken or raised).
+
+ \section1 Edge Class Definition
+
+ The \e Edge class represents the arrow-lines between the nodes in this
+ example. The class is very simple: it maintains a source- and destination
+ node pointer, and provides an \e adjust() function that makes sure the line
+ starts at the position of the source, and ends at the position of the
+ destination. The edges are the only items that change continuously as
+ forces pull and push on the nodes.
+
+ Let's take a look at the class declaration:
+
+ \snippet examples/graphicsview/elasticnodes/edge.h 0
+
+ \e Edge inherits from QGraphicsItem, as it's a simple class that has no use
+ for signals, slots, and properties (compare to QGraphicsObject).
+
+ The constructor takes two node pointers as input. Both pointers are
+ mandatory in this example. We also provide get-functions for each node.
+
+ The \e adjust() function repositions the edge, and the item also implements
+ \l{QGraphicsItem::boundingRect()}{boundingRect()} and
+ \{QGraphicsItem::paint()}{paint()}.
+
+ We will now review its implementation.
+
+ \snippet examples/graphicsview/elasticnodes/edge.cpp 0
+
+ The \e Edge constructor initializes its arrowSize data member to 10 units;
+ this determines the size of the arrow which is drawn in
+ \l{QGraphicsItem::paint()}{paint()}.
+
+ In the constructor body, we call
+ \l{QGraphicsItem::setAcceptedMouseButtons()}{setAcceptedMouseButtons(0)}.
+ This ensures that the edge items are not considered for mouse input at all
+ (i.e., you cannot click the edges). Then, the source and destination
+ pointers are updated, this edge is registered with each node, and we call
+ \e adjust() to update this edge's start end end position.
+
+ \snippet examples/graphicsview/elasticnodes/edge.cpp 1
+
+ The source and destination get-functions simply return the respective
+ pointers.
+
+ \snippet examples/graphicsview/elasticnodes/edge.cpp 2
+
+ In \e adjust(), we define two points: \e sourcePoint, and \e destPoint,
+ pointing at the source and destination nodes' origins respectively. Each
+ point is calculated using \l{The Graphics View Coordinate System}{local
+ coordinates}.
+
+ We want the tip of the edge's arrows to point to the exact outline of the
+ nodes, as opposed to the center of the nodes. To find this point, we first
+ decompose the vector pointing from the center of the source to the center
+ of the destination node into X and Y, and then normalize the components by
+ dividing by the length of the vector. This gives us an X and Y unit delta
+ that, when multiplied by the radius of the node (which is 10), gives us the
+ offset that must be added to one point of the edge, and subtracted from the
+ other.
+
+ If the length of the vector is less than 20 (i.e., if two nodes overlap),
+ then we fix the source and destination pointer at the center of the source
+ node. In practise this case is very hard to reproduce manually, as the
+ forces between the two nodes is then at its maximum.
+
+ It's important to notice that we call
+ \l{QGraphicsItem::prepareGeometryChange()}{prepareGeometryChange()} in this
+ function. The reason is that the variables \e sourcePoint and \e destPoint
+ are used directly when painting, and they are returned from the
+ \l{QGraphicsItem::boundingRect()}{boundingRect()} reimplementation. We must
+ always call
+ \l{QGraphicsItem::prepareGeometryChange()}{prepareGeometryChange()} before
+ changing what \l{QGraphicsItem::boundingRect()}{boundingRect()} returns,
+ and before these variables can be used by
+ \l{QGraphicsItem::paint()}{paint()}, to keep Graphics View's internal
+ bookkeeping clean. It's safest to call this function once, immediately
+ before any such variable is modified.
+
+ \snippet examples/graphicsview/elasticnodes/edge.cpp 3
+
+ The edge's bounding rectangle is defined as the smallest rectangle that
+ includes both the start and the end point of the edge. Because we draw an
+ arrow on each edge, we also need to compensate by adjusting with half the
+ arrow size and half the pen width in all directions. The pen is used to
+ draw the outline of the arrow, and we can assume that half of the outline
+ can be drawn outside of the arrow's area, and half will be drawn inside.
+
+ \snippet examples/graphicsview/elasticnodes/edge.cpp 4
+
+ We start the reimplementation of \l{QGraphicsItem::paint()}{paint()} by
+ checking a few preconditions. Firstly, if either the source or destination
+ node is not set, then we return immediately; there is nothing to draw.
+
+ At the same time, we check if the length of the edge is approximately 0,
+ and if it is, then we also return.
+
+ \snippet examples/graphicsview/elasticnodes/edge.cpp 5
+
+ We draw the line using a pen that has round joins and caps. If you run the
+ example, zoom in and study the edge in detail, you will see that there are
+ no sharp/square edges.
+
+ \snippet examples/graphicsview/elasticnodes/edge.cpp 6
+
+ We proceed to drawing one arrow at each end of the edge. Each arrow is
+ drawn as a polygon with a black fill. The coordinates for the arrow are
+ determined using simple trigonometry.
+
+ \section1 GraphWidget Class Definition
+
+ \e GraphWidget is a subclass of QGraphicsView, which provides the main
+ window with scrollbars.
+
+ \snippet examples/graphicsview/elasticnodes/graphwidget.h 0
+
+ It provides a basic constructor that initializes the scene, an \e
+ itemMoved() function to notify changes in the scene's node graph, a few
+ event handlers, a reimplementation of
+ \l{QGraphicsView::drawBackground()}{drawBackground()}, and a helper
+ function for scaling the view by mouse or keyboard.
+
+ \snippet examples/graphicsview/elasticnodes/graphwidget.cpp 0
+
+ \e GraphicsWidget's constructor creates the scene, and because most items
+ move around most of the time, it sets QGraphicsScene::NoIndex. Then the
+ scene gets a fixed \l{QGraphicsScene::sceneRect}{scene rectangle}.
+ The scene is then assigned to the \e GraphWidget view.
+
+ The view enables QGraphicsView::CacheBackground to cache rendering of its
+ static and somewhat complex background. Because the graph renders a close
+ collection of small items that all move around, it's unnecessary for
+ Graphics View to waste time finding accurate update regions, so we set the
+ QGraphicsView::BoundingRectViewportUpdate viewport update mode. The default
+ would work fine, but this mode is noticably faster for this example.
+
+ To improve rendering quality, we set QPainter::Antialiasing.
+
+ The transformation anchor decides how the view should scroll when you
+ transform the view, or in our case, when we zoom in or out. We have chosen
+ QGraphicsView::AnchorUnderMouse, which centers the view on the point under
+ the mouse cursor. This makes it easy to zoom towards a point in the scene
+ by moving the mouse over it, and then rolling the mouse wheel.
+
+ Finally we give the window a minimum size that matches the scene's default
+ size, and set a suitable window title.
+
+ \snippet examples/graphicsview/elasticnodes/graphwidget.cpp 1
+
+ The last part of the constructor creates the grid of nodes and edges, and
+ gives each node an initial position.
+
+ \snippet examples/graphicsview/elasticnodes/graphwidget.cpp 2
+
+ \e GraphWidget is notified of node movement through this \e itemMoved()
+ function. Its job is simply to restart the main timer in case it's not
+ running already. The timer is designed to stop when the graph stabilizes,
+ and start once it's unstable again.
+
+ \snippet examples/graphicsview/elasticnodes/graphwidget.cpp 3
+
+ This is \e GraphWidget's key event handler. The arrow keys move the center
+ node around, the '+' and '-' keys zoom in and out by calling \e
+ scaleView(), and the enter and space keys randomize the positions of the
+ nodes. All other key events (e.g., page up and page down) are handled by
+ QGraphicsView's default implementation.
+
+ \snippet examples/graphicsview/elasticnodes/graphwidget.cpp 4
+
+ The timer event handler's job is to run the whole force calculation
+ machinery as a smooth animation. Each time the timer is triggered, the
+ handler will find all nodes in the scene, and call \e
+ Node::calculateForces() on each node, one at a time. Then, in a final step
+ it will call \e Node::advance() to move all nodes to their new positions.
+ By checking the return value of \e advance(), we can decide if the grid
+ stabilized (i.e., no nodes moved). If so, we can stop the timer.
+
+ \snippet examples/graphicsview/elasticnodes/graphwidget.cpp 5
+
+ In the wheel event handler, we convert the mouse wheel delta to a scale
+ factor, and pass this factor to \e scaleView(). This approach takes into
+ account the speed that the wheel is rolled. The faster you roll the mouse
+ wheel, the faster the view will zoom.
+
+ \snippet examples/graphicsview/elasticnodes/graphwidget.cpp 6
+
+ The view's background is rendered in a reimplementation of
+ QGraphicsView::drawBackground(). We draw a large rectangle filled with a
+ linear gradient, with a drop shadow, and then render text in top. The text
+ is rendered twice to give a similar simple drop-shadow effect.
+
+ This background rendering is quite expensive; this is why the view enables
+ QGraphicsView::CacheBackground.
+
+ \snippet examples/graphicsview/elasticnodes/graphwidget.cpp 7
+
+ The \e scaleView() helper function checks that the scale factor stays
+ within certain limits (i.e., you cannot zoom too far in nor too far out),
+ and then applies this scale.
+
+ \section1 The main() Function
+
+ In contrast to the complexity of the rest of this example, the \e main()
+ function is very simple: We create a QApplication instance, seed the
+ randomizer using qsrand(), and then create and show an instance of \e
+ GraphWidget. Because all nodes in the grid are moved initially, the \e
+ GraphWidget timer will start immediately after control has returned to the
+ event loop.
*/
diff --git a/doc/src/examples/qml-examples.qdoc b/doc/src/examples/qml-examples.qdoc
new file mode 100644
index 0000000000..93e4a4689d
--- /dev/null
+++ b/doc/src/examples/qml-examples.qdoc
@@ -0,0 +1,260 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+/*!
+ \title Animations
+ \example declarative/animations
+
+ This example shows how to use animations in QML.
+*/
+
+/*!
+ \title AspectRatio
+ \example declarative/aspectratio
+
+ This example shows how to implement different aspect ratios in QML.
+*/
+
+/*!
+ \example declarative/behaviors
+ \title Behaviors
+*/
+
+/*!
+ \title Border Image
+ \example declarative/border-image
+
+ This example shows how to use a BorderImage in QML.
+*/
+
+/*!
+ \title Clocks
+ \example declarative/clocks
+
+ This example shows how to create a Clock component and reuse it in a grid.
+*/
+
+/*!
+ \title Connections
+ \example declarative/connections
+
+ This example shows how to use a Connection element in QML.
+*/
+
+/*!
+ \title Dial
+ \example declarative/dial
+
+ This example shows how to implement a dial in QML.
+*/
+
+/*!
+ \title Dynamic
+ \example declarative/dynamic
+
+ This example shows how to create dynamic objects QML.
+*/
+
+/*!
+ \example declarative/extending
+ \title Extending
+*/
+
+/*!
+ \example declarative/fillmode
+ \title Fillmode
+*/
+
+/*!
+ \title Flipable
+ \example declarative/flipable
+
+ This example shows how to use a Flipable element in QML.
+*/
+
+/*!
+ \title Focus
+ \example declarative/focus
+
+ This example shows how to handle keys and focus in QML.
+
+ \image qml-focus-example.png
+*/
+
+/*!
+ \example declarative/fonts
+ \title Fonts
+*/
+
+/*!
+ \example declarative/gridview
+ \title GridView
+*/
+
+/*!
+ \example declarative/imageprovider
+ \title Image Provider
+*/
+
+/*!
+ \example declarative/images
+ \title Images
+*/
+
+/*!
+ \example declarative/layouts
+ \title Layouts
+*/
+
+/*!
+ \example declarative/listmodel-threaded
+ \title ListModel Threaded
+*/
+
+/*!
+ \example declarative/listview
+ \title ListView
+*/
+
+/*!
+ \example declarative/mousearea
+ \title Mouse Area
+*/
+
+/*!
+ \example declarative/objectlistmodel
+ \title Object ListModel
+*/
+
+/*!
+ \example declarative/package
+ \title Package
+*/
+
+/*!
+ \example declarative/parallax
+ \title Parallax
+*/
+
+/*!
+ \example declarative/plugins
+ \title Plugins
+*/
+
+/*!
+ \example declarative/progressbar
+ \title Progress Bars
+*/
+
+/*!
+ \example declarative/proxywidgets
+ \title Proxy Widgets
+*/
+
+/*!
+ \example declarative/scrollbar
+ \title Scrollbar
+*/
+
+/*!
+ \example declarative/searchbox
+ \title Search Box
+*/
+
+/*!
+ \example declarative/slideswitch
+ \title Slide Switch
+*/
+
+/*!
+ \example declarative/sql
+ \title SQL
+*/
+
+/*!
+ \example declarative/states
+ \title States
+*/
+
+/*!
+ \example declarative/stringlistmodel
+ \title String ListModel
+*/
+
+/*!
+ \example declarative/tabwidget
+ \title Tab Widget
+*/
+
+/*!
+ \example declarative/tic-tac-toe
+ \title Tic-Tac-Toe
+*/
+
+/*!
+ \example declarative/tvtennis
+ \title TV Tennis
+*/
+
+/*!
+ \example declarative/velocity
+ \title Velocity
+*/
+
+/*!
+ \example declarative/webview
+ \title WebView
+*/
+
+/*!
+ \example declarative/workerscript
+ \title WorkerScript
+*/
+
+/*!
+ \example declarative/xmldata
+ \title XML Data
+*/
+
+/*!
+ \example declarative/xmlhttprequest
+ \title XMLHttpRequest
+*/
diff --git a/doc/src/examples/qml-focus.qdoc b/doc/src/examples/qml-focus.qdoc
deleted file mode 100644
index 92d93b2279..0000000000
--- a/doc/src/examples/qml-focus.qdoc
+++ /dev/null
@@ -1,49 +0,0 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
-
-/*!
- \title Focus
- \example declarative/focus
-
- This example shows how to handle keys and focus in QML.
-
- \image qml-focus-example.png
-*/
diff --git a/doc/src/getting-started/examples.qdoc b/doc/src/getting-started/examples.qdoc
index 071a1070c9..542f672607 100644
--- a/doc/src/getting-started/examples.qdoc
+++ b/doc/src/getting-started/examples.qdoc
@@ -649,8 +649,8 @@
\list
\o \l{graphicsview/collidingmice}{Colliding Mice}\raisedaster
\o \l{graphicsview/diagramscene}{Diagram Scene}\raisedaster
- \o \l{graphicsview/dragdroprobot}{Drag and Drop Robot}
- \o \l{graphicsview/elasticnodes}{Elastic Nodes}
+ \o \l{graphicsview/dragdroprobot}{Drag and Drop Robot}\raisedaster
+ \o \l{graphicsview/elasticnodes}{Elastic Nodes}\raisedaster
\o \l{graphicsview/portedasteroids}{Ported Asteroids}
\o \l{graphicsview/portedcanvas}{Ported Canvas}
\endlist
diff --git a/doc/src/getting-started/installation.qdoc b/doc/src/getting-started/installation.qdoc
index 3a9d4ea29a..3ea351e35f 100644
--- a/doc/src/getting-started/installation.qdoc
+++ b/doc/src/getting-started/installation.qdoc
@@ -697,6 +697,209 @@ If you are using pre-built binaries, follow the instructions given in the
\endlist
*/
+/*! \page install-Symbian-linux.html
+\title Installing Qt on the Symbian platform using Linux (experimental)
+\ingroup installation
+\ingroup qtsymbian
+\brief How to install Qt on the Symbian platform using Linux.
+
+\note Qt for the Symbian platform has some requirements that are given in more detail
+in the \l{Qt for the Symbian platform Requirements} document. TODO list requirements like SDK here.
+
+\note \bold {This document describes how to install and configure Qt for
+the Symbian platform from scratch, using Linux as the build host.
+Qt does not come with a binary package for Linux yet, but if you want to avoid
+the full build of Qt and start developing applications right away, you can
+download drop-in binaries from here: TODO}
+
+\list 1
+
+ \o Setup the development environment
+
+ TODO Make sure your Symbian development environment is correctly installed and
+ patched as explained in the \l{Qt for the Symbian platform Requirements} document.
+
+ \o Install Qt
+
+ Uncompress the \l{http://qt.nokia.com/downloads}{downloaded} source package into the
+ directory you want Qt installed, e.g. \c{/home/user/qt/%VERSION%}.
+
+ \o Environment variables
+
+ In order to build and use Qt, the \c PATH environment variable needs
+ to be extended to fine Qt tools and also to find the Symbian platform tools:
+
+ First you need to set the \c EPOCROOT environment variable to point to the location
+ of your S60 SDK:
+
+ \snippet doc/src/snippets/code/doc_src_installation.qdoc 36
+
+ Then you can update the PATH variable;
+
+ \snippet doc/src/snippets/code/doc_src_installation.qdoc 37
+
+ \o Configure Qt
+
+ To configure Qt for the Symbian platform, do:
+
+ \snippet doc/src/snippets/code/doc_src_installation.qdoc 38
+ to build the libraries using RVCT or
+ \snippet doc/src/snippets/code/doc_src_installation.qdoc 39
+ to build the libraries using GCCE.
+
+ \o Build Qt
+
+ To build Qt for the device, type:
+
+ \snippet doc/src/snippets/code/doc_src_installation.qdoc 40
+
+ Congratulations, Qt is now ready to use.
+
+ \o Building Qt packages for the device
+
+ To run any application or demo on a real device, you need to install it
+ on the device. To do this you first have to create a a package for the
+ device, containing the libraries:
+
+ \list A
+ \o Building a Qt package without a certificate
+
+ If you have no certificate, build a self signed Qt:
+
+ \snippet doc/src/snippets/code/doc_src_installation.qdoc 41
+
+ The Qt libraries are built with "All -Tcb" capability, so that
+ they can support all types of applications. However, these
+ capabilities are automatically lowered if you make a selfsigned
+ package.
+
+ \o Building a Qt package with a Symbian developer certificate
+
+ If you have a symbian-signed developer certificate, specify the
+ capabilities you can sign for, for example:
+
+ \snippet doc/src/snippets/code/doc_src_installation.qdoc 42
+ \endlist
+
+ \o Installing Qt packages to the device.
+
+ It is possible to install packages to a phone in Linux by putting
+ the package on the phone memory card and then installing manually
+ from the phone menu. However, this is tedious and will not work
+ on phones without a memory card, so the method recommended by Qt is
+ to use the App TRK tool.
+
+ \list a
+ \o Obtaining the App TRK package.
+
+ Download the package from the following location.
+
+ \list
+ \o \l{http://tools.ext.nokia.com/trk/}{Application TRK}.
+ Choose the correct installation package based on the
+ S60 version of your device
+ (\c{S60_<S60-version>_app_trk_<TRK-version>.sisx}).
+ \endlist
+
+ This package currently has to be installed by putting the
+ package on the memory card and installing from the phone
+ menu, or using a Windows PC for doing the install. However,
+ the installation only has to be done once.
+
+ \o Configuring App TRK on the phone.
+
+ When App TRK is installed, connect the phone to the PC using
+ the USB cable. Select "PCSuite" as connection type. Then run
+ App TRK on the phone, and make sure that the connection type is
+ USB. This can be changed under
+ the \c Settings menu entry. If necessary, choose \c Connect
+ from the menu.
+
+ \o Configuring the USB serial driver on the Linux system.
+
+ On Linux, phone should appear as the \c /dev/ttyUSB1 device,
+ however if you are running an old kernel, you may need to
+ force the USB module to be loaded correctly before the device
+ will appear:
+
+ \snippet doc/src/snippets/code/doc_src_installation.qdoc 43
+
+ Note the identifier on the line where your Symbian device
+ appears. Then execute the following, using the first and
+ second part of the identifier in place of \c XXXX,
+ respectively.
+
+ \snippet doc/src/snippets/code/doc_src_installation.qdoc 44
+
+ The \c rmmod step may fail if the module is not already
+ loaded, but that is harmless.
+
+ \o Building the \c runonphone tool.
+
+ Note that building the \c runonphone tool requires a separate
+ installation of Qt for Linux. If there is a version of Qt
+ installed by your distribution's package mechanism, that that
+ should do fine. Some distributions separate the libraries from
+ the development setup which includes qmake. Make sure you have
+ both installed.
+
+ First make sure that the \c qmake you use is taken from the
+ Linux installation of Qt. The easiest way to make sure of this
+ is to open a new shell and run the following command:
+
+ \snippet doc/src/snippets/code/doc_src_installation.qdoc 45
+
+ \c qmake will tell you where it is installed.
+
+ Copy the \c{%QTDIR%/tools/runonphone} folder to a place outside
+ of the Qt tree. Then go to the folder in a shell and build it:
+
+ \snippet doc/src/snippets/code/doc_src_installation.qdoc 46
+
+ Copy the resulting executable to a folder which is in your
+ \c PATH environment variable.
+
+ \o Installing the built package onto the phone.
+
+ Return to the root of the Qt tree configured for Symbian. Then
+ install the Qt libraries by running the following:
+
+ \snippet doc/src/snippets/code/doc_src_installation.qdoc 47
+
+ \note If the installation fails, please make sure that there is
+ no previously installed version of Qt on the phone.
+
+ Qt requires some dependent packages to be installed on the device,
+ they are shipped in the Symbian SDK and can be installed using the
+ runonphone tool as well.
+ The packages can be found in the EPOCROOT at the following locations;
+
+ \snippet doc/src/snippets/code/doc_src_installation.qdoc 50
+
+ \endlist
+
+ \o Running Qt demos
+
+ We've included a subset of the Qt demos in this package for you
+ to try out. An excellent starting point is the "fluidlauncher"
+ demo.
+
+ Install and run the demo by using the following commands:
+
+ \snippet doc/src/snippets/code/doc_src_installation.qdoc 48
+
+ The same command can be used for other applications:
+
+ \snippet doc/src/snippets/code/doc_src_installation.qdoc 49
+
+ For more information about building and running Qt programs on the
+ Symbian platform, see \l{The Symbian platform - Introduction to Qt}.
+
+ We hope you will enjoy using Qt.
+
+\endlist
+
+*/
/*!
\page requirements.html
\title General Qt Requirements
diff --git a/doc/src/platforms/platform-notes.qdoc b/doc/src/platforms/platform-notes.qdoc
index 83f2833aaa..8f5b6a558f 100644
--- a/doc/src/platforms/platform-notes.qdoc
+++ b/doc/src/platforms/platform-notes.qdoc
@@ -411,7 +411,7 @@
\section1 Source Compatibility
Qt for Symbian provides the same level of source compatibility guarantee as
- given for other platforms.  That is, a program which compiles against a given
+ given for other platforms. That is, a program which compiles against a given
version of Qt for Symbian will also compile against all future versions of the
same major release.
@@ -496,28 +496,31 @@
\section1 Required Capabilities
- Distributions of Qt are typically signed with \c{All -TCB}. What your
- application needs to be signed with in order to function with Qt depends
- on what functionality it uses:
+ The Qt libraries are typically signed with \c{All -TCB} capabilites, but
+ that does not mean your Qt application needs to be signed with the same
+ capabilities to function properly. The capabilities your application needs
+ to function properly depends on which parts of Qt you use, here is an
+ overview:
\table
- \header \o Technology
+ \header \o Module
\o Required Symbian Capability
\row \o QtCore
- \o \c PowerMgmt if applications are terminated using QProcess.
+ \o \c PowerMgmt if QProcess::kill(...) or QProcess::terminate(...) is called.
+ \row \o QtCore
+ \o \c AllFiles when \l{http://developer.symbian.org/wiki/index.php/Capabilities_%28Symbian_Signed%29/AllFiles_Capability}{accessing specific areas.}
\row \o QtNetwork
- \o NetworkServices
+ \o \c NetworkServices is basically always required for this module.
\row \o QtMultiMedia
\o \c UserEnvironment if QAudioInput is used.
\endtable
- Depending on what file paths that are accessed and how AllFiles may be
- required. Similarly, if the network is accessed indirectly through
- components such as QtXmlPatterns, QtWebkit or QtScript, the capabilities
- needs to match accordingly.
+ Note that some modules rely on other modules. If your application uses
+ QtXmlPatterns, QtWebkit or QtScript it may still require \c NetworkServices
+ \o as these modules rely on QtNetwork to go online.
- See individual classes' documentation for specifics. If a class does not
- mention Symbian capabilities, it requires none.
+ For more information see the documentation of the individual Qt classes. If
+ a class does not mention Symbian capabilities, it requires none.
\section1 Multimedia and Phonon Support
diff --git a/doc/src/snippets/code/doc_src_installation.qdoc b/doc/src/snippets/code/doc_src_installation.qdoc
index b3c99038ff..ac94cf7a15 100644
--- a/doc/src/snippets/code/doc_src_installation.qdoc
+++ b/doc/src/snippets/code/doc_src_installation.qdoc
@@ -225,10 +225,8 @@ SYMBIANBUILD_DEPENDENCYOFF=1
//! [34]
cd src\s60installs
-patch_capabilities.pl Qt_template.pkg release-armv5
make sis QT_SIS_OPTIONS=-i
cd ..\3rdparty\webkit\WebCore
-patch_capabilities.pl QtWebkit_template.pkg release-armv5
make sis QT_SIS_OPTIONS=-i
//! [34]
@@ -240,3 +238,87 @@ cd ..\3rdparty\webkit\WebCore
patch_capabilities.pl QtWebKit_template.pkg release-armv5 "ALL -Tcb -AllFiles -DRM"
make sis QT_SIS_OPTIONS=-i QT_SIS_CERTIFICATE=<certificate file> QT_SIS_KEY=<certificate key file>
//! [35]
+
+//! [36]
+EPOCROOT=/home/user/s60-sdk/
+export EPOCROOT
+//! [36]
+
+//! [37]
+PATH=/home/user/qt/%VERSION%/bin:$EPOCROOT/epoc32/tools:$PATH
+export PATH
+//! [37]
+
+//! [38]
+cd /home/user/qt/%VERSION%
+./configure -platform linux-g++ -xplatform symbian/linux-armcc -arch symbian
+//! [38]
+
+//! [39]
+cd /home/user/qt/%VERSION%
+./configure -platform linux-g++ -xplatform symbian/linux-gcce -arch symbian -no-webkit
+//! [39]
+
+//! [40]
+make
+//! [40]
+
+//! [41]
+cd src/s60installs
+make sis
+//! [41]
+
+//! [42]
+cd src/s60installs
+patch_capabilities.pl Qt_template.pkg - "ALL -Tcb -AllFiles -DRM"
+make sis QT_SIS_CERTIFICATE=<certificate file> QT_SIS_KEY=<certificate key file>
+cd ../3rdparty/webkit/WebCore
+patch_capabilities.pl QtWebKit_template.pkg - "ALL -Tcb -AllFiles -DRM"
+make sis QT_SIS_CERTIFICATE=<certificate file> QT_SIS_KEY=<certificate key file>
+//! [42]
+
+//! [43]
+lsusb
+//! [43]
+
+//! [44]
+sudo rmmod usbserial
+sudo modprobe usbserial vendor=0x0XXX product=0x0XXX
+//! [44]
+
+//! [45]
+$ qmake -version
+QMake version 2.01a
+Using Qt version 4.6.2 in /usr/lib/qt4
+//! [45]
+
+//! [46]
+cd $HOME/runonphone
+qmake
+make
+//! [46]
+
+//! [47]
+runonphone -s lib/Qt.sis
+//! [47]
+
+//! [48]
+cd demos/embedded/fluidlauncher
+runonphone -s fluidlauncher.sis fluidlauncher.exe
+//! [48]
+
+//! [49]
+cd myapp
+qmake
+make
+make sis
+runonphone -s myapp.sis myapp.exe
+//! [49]
+
+//! [50]
+nokia_plugin/openc/s60opencsis/openc_ssl_s60_1_6_ss.sis
+nokia_plugin/openc/s60opencsis/pips_s60_1_6_ss.sis
+nokia_plugin/opencpp/s60opencppsis/stdcpp_s60_1_6_ss.sis
+//! [50]
+
+