summaryrefslogtreecommitdiffstats
path: root/doc/src/declarative
diff options
context:
space:
mode:
authorDavid Boddie <dboddie@trolltech.com>2010-07-16 15:46:21 (GMT)
committerDavid Boddie <dboddie@trolltech.com>2010-07-16 15:46:21 (GMT)
commit6b1b666574d6e27efdd3b243de8815a5278c3666 (patch)
tree7a5ac02fe569b3fc497ca8d0a333d10587eb3567 /doc/src/declarative
parenteef1d13743baddf41bd135d98fc2ad12944b8477 (diff)
parentab4dde176cfa314522964e5e5fbf9f2d388f8fdf (diff)
downloadQt-6b1b666574d6e27efdd3b243de8815a5278c3666.zip
Qt-6b1b666574d6e27efdd3b243de8815a5278c3666.tar.gz
Qt-6b1b666574d6e27efdd3b243de8815a5278c3666.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7
Conflicts: tools/qdoc3/test/qt.qdocconf
Diffstat (limited to 'doc/src/declarative')
-rw-r--r--doc/src/declarative/advtutorial.qdoc11
-rw-r--r--doc/src/declarative/anchor-layout.qdoc5
-rw-r--r--doc/src/declarative/basictypes.qdoc26
-rw-r--r--doc/src/declarative/declarativeui.qdoc16
-rw-r--r--doc/src/declarative/elements.qdoc3
-rw-r--r--doc/src/declarative/examples.qdoc13
-rw-r--r--doc/src/declarative/extending-tutorial.qdoc340
-rw-r--r--doc/src/declarative/extending.qdoc43
-rw-r--r--doc/src/declarative/focus.qdoc2
-rw-r--r--doc/src/declarative/globalobject.qdoc2
-rw-r--r--doc/src/declarative/modules.qdoc15
-rw-r--r--doc/src/declarative/network.qdoc4
-rw-r--r--doc/src/declarative/pics/extending-tutorial-chapter1.pngbin0 -> 6687 bytes
-rw-r--r--doc/src/declarative/pics/extending-tutorial-chapter2.pngbin0 -> 7318 bytes
-rw-r--r--doc/src/declarative/pics/extending-tutorial-chapter3.pngbin0 -> 8145 bytes
-rw-r--r--doc/src/declarative/pics/extending-tutorial-chapter5.pngbin0 -> 5557 bytes
-rw-r--r--doc/src/declarative/pics/imageprovider.pngbin0 -> 420 bytes
-rw-r--r--doc/src/declarative/qdeclarativedebugging.qdoc8
-rw-r--r--doc/src/declarative/qdeclarativei18n.qdoc8
-rw-r--r--doc/src/declarative/qdeclarativeperformance.qdoc21
-rw-r--r--doc/src/declarative/qml-intro.qdoc24
-rw-r--r--doc/src/declarative/qmlviewer.qdoc4
-rw-r--r--doc/src/declarative/qtprogrammers.qdoc12
-rw-r--r--doc/src/declarative/tutorial.qdoc4
24 files changed, 382 insertions, 179 deletions
diff --git a/doc/src/declarative/advtutorial.qdoc b/doc/src/declarative/advtutorial.qdoc
index 740f6f9..1341bbb 100644
--- a/doc/src/declarative/advtutorial.qdoc
+++ b/doc/src/declarative/advtutorial.qdoc
@@ -314,18 +314,17 @@ In anticipation of the new block animations, \c Block.qml file is now renamed to
\section3 Animating block movement
First we will animate the blocks so that they move in a fluid manner. QML has a number of methods for adding fluid
-movement, and in this case we're going to use the \l SpringFollow element to add an animation with a spring-like
-movement. In \c BoomBlock.qml, we apply a \l SpringFollow
-to the \c x and \c y properties so that the block will follow and animate its movement towards the
-position specified by the new \c targetX and \c targetY properties (whose values will be set by \c samegame.js).
-Here is the code added to \c BoomBlock.qml:
+movement, and in this case we're going to use the \l Behavior element to add a \l SpringAnimation.
+In \c BoomBlock.qml, we apply a \l SpringAnimation behavior to the \c x and \c y properties so that the
+block will follow and animate its movement in a spring-like fashion towards the specified position (whose
+values will be set by \c samegame.js).Here is the code added to \c BoomBlock.qml:
\snippet declarative/tutorials/samegame/samegame4/content/BoomBlock.qml 1
The \c spring and \c damping values can be changed to modify the spring-like effect of the animation.
The \c {enabled: spawned} setting refers to the \c spawned value that is set from \c createBlock() in \c samegame.js.
-This ensures the \l SpringFollow on the \c x is only enabled after \c createBlock() has set the block to
+This ensures the \l SpringAnimation on the \c x is only enabled after \c createBlock() has set the block to
the correct position. Otherwise, the blocks will slide out of the corner (0,0) when a game begins, instead of falling
from the top in rows. (Try commenting out \c {enabled: spawned} and see for yourself.)
diff --git a/doc/src/declarative/anchor-layout.qdoc b/doc/src/declarative/anchor-layout.qdoc
index 9c217e1..5c025e5 100644
--- a/doc/src/declarative/anchor-layout.qdoc
+++ b/doc/src/declarative/anchor-layout.qdoc
@@ -33,7 +33,10 @@
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.
+\l {Item::anchors.left}{left}, \l {Item::anchors.horizontalCenter}{horizontalCenter},
+\l {Item::anchors.right}{right}, \l {Item::anchors.top}{top},
+\l {Item::anchors.verticalCenter}{verticalCenter}, \l {Item::anchors.baseline}{baseline},
+and \l {Item::anchors.bottom}{bottom}.
\image edges_qml.png
diff --git a/doc/src/declarative/basictypes.qdoc b/doc/src/declarative/basictypes.qdoc
index 159f40d..e327d4a 100644
--- a/doc/src/declarative/basictypes.qdoc
+++ b/doc/src/declarative/basictypes.qdoc
@@ -107,6 +107,9 @@
Text { text: "Hello world!" }
\endqml
+ Strings have a \c length attribute that holds the number of
+ characters in the string.
+
\sa {QML Basic Types}
*/
@@ -400,3 +403,26 @@
\sa {QML Basic Types}
*/
+
+/*!
+ \qmlbasictype enumeration
+ \ingroup qmlbasictypes
+
+ \brief An enumeration type consists of a set of named values.
+
+ An enumeration type consists of a set of named values.
+
+ An enumeration value may be specifed as either a string:
+ \qml
+ Text { horizontalAlignment: "AlignRight" }
+ \endqml
+
+ or as \c {<Element>.<value>}:
+ \qml
+ Text { horizontalAlignment: Text.AlignRight }
+ \endqml
+
+ The second form is preferred.
+
+ \sa {QML Basic Types}
+*/
diff --git a/doc/src/declarative/declarativeui.qdoc b/doc/src/declarative/declarativeui.qdoc
index 4235c27..217e372 100644
--- a/doc/src/declarative/declarativeui.qdoc
+++ b/doc/src/declarative/declarativeui.qdoc
@@ -37,7 +37,9 @@ custom user interfaces from a rich set of \l {QML Elements}{QML elements}.
Qt Quick helps programmers and designers collaborate to
build the fluid user interfaces that are becoming common in portable
consumer devices, such as mobile phones, media players, set-top boxes
-and netbooks.
+and netbooks. Qt Quick consists of the QtDeclarative C++ module, QML, and
+the integration of both of these into the Qt Creator IDE. Using the QtDeclarative
+C++ module, you can load and interact with QML files from your Qt application.
QML is an extension to \l
{http://www.ecma-international.org/publications/standards/Ecma-262.htm}
@@ -58,7 +60,7 @@ complete internet-enabled applications like a \l
Qt Quick builds on \l {QML for Qt programmers}{Qt's existing
strengths}. QML can be be used to incrementally extend an existing
application or to build completely new applications. QML is fully \l
-{Extending QML in C++}{extensible from C++}.
+{Extending QML in C++}{extensible from C++} through the QtDeclarative Module.
\section1 Getting Started
@@ -74,15 +76,15 @@ application or to build completely new applications. QML is fully \l
\list
\o \l {QML Documents}
\o \l {Property Binding}
-\o \l {Integrating JavaScript}
-\o \l {QML Scope}
\o \l {Network Transparency}
+\o \l {QML Scope}
+\o \l {Integrating JavaScript}
\o \l {Data Models}
\o \l {anchor-layout.html}{Anchor-based Layout}
\o \l {qdeclarativestates.html}{States}
\o \l {qdeclarativeanimation.html}{Animation}
-\o \l {qdeclarativemodules.html}{Modules}
\o \l {qdeclarativefocus.html}{Keyboard Focus}
+\o \l {qdeclarativemodules.html}{Modules}
\o \l {Extending types from QML}
\o \l {qdeclarativedynamicobjects.html}{Dynamic Object Creation}
\o \l {qmlruntime.html}{The Qt Declarative Runtime}
@@ -90,10 +92,10 @@ application or to build completely new applications. QML is fully \l
\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}
+\o \l {Tutorial: Writing QML extensions with C++}
+\o \l {Extending QML in C++}
\endlist
\section1 Reference
diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc
index 349a8ed..c2930b3 100644
--- a/doc/src/declarative/elements.qdoc
+++ b/doc/src/declarative/elements.qdoc
@@ -76,11 +76,10 @@ The following table lists the QML elements provided by the \l {QtDeclarative}{Qt
\row \o \l {AnchorAnimation} \o Animates anchor changes
\row \o \l {PauseAnimation} \o Pauses an animation
\row \o \l {SmoothedAnimation} \o Allows a property to smoothly track a value
+\row \o \l {SpringAnimation} \o Allows a property to track a value in a spring-like motion
\row \o \l {PropertyAction} \o Sets immediate property changes during animation
\row \o \l {ScriptAction} \o Runs scripts during an animation
\row \o \l {Transition} \o Animates transitions during state changes
-\row \o \l {SpringFollow} \o Allows a property to follow value changes
-\row \o \l {SmoothedFollow} \o Allows animation to smoothly follow value changes
\header \o {2,1} \bold {Working with Data}
\row \o \l {Binding} \o Binds any value to any property
diff --git a/doc/src/declarative/examples.qdoc b/doc/src/declarative/examples.qdoc
index 587cdf2..8a24228 100644
--- a/doc/src/declarative/examples.qdoc
+++ b/doc/src/declarative/examples.qdoc
@@ -36,11 +36,18 @@ Qt includes a set of examples and demos that show how to use various aspects
of QML. The examples are small demonstrations of particular QML components,
while the demos contain more complete and functional applications.
-To run the examples and demos, you can use Qt Creator or the included \l {Qt Declarative UI Runtime}{qmlviewer}
-command-line application. For example, from your build directory, run:
+To run the examples and demos, open them in Qt Creator or use the included
+\l {QML Viewer} tool. The \l {QML Viewer} can be run from the command line:
\code
- bin/qmlviewer $QTDIR/demos/declarative/samegame/samegame.qml
+ qmlviewer $QTDIR/demos/declarative/samegame/samegame.qml
+\endcode
+
+On Mac OS X, you can run the included "QMLViewer" application from the
+Finder, or use the command line:
+
+\code
+ QMLViewer.app/Contents/MacOS/QMLViewer $QTDIR/demos/declarative/samegame/samegame.qml
\endcode
diff --git a/doc/src/declarative/extending-tutorial.qdoc b/doc/src/declarative/extending-tutorial.qdoc
index 0cb3a7d..cc93e86 100644
--- a/doc/src/declarative/extending-tutorial.qdoc
+++ b/doc/src/declarative/extending-tutorial.qdoc
@@ -48,8 +48,9 @@ Tutorial chapters:
\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}
+\o \l{declarative/tutorials/extending/chapter5-listproperties}{Using List Property Types}
+\o \l{declarative/tutorials/extending/chapter6-plugins}{Writing an Extension Plugin}
+\o \l{qml-extending-tutorial7.html}{In Summary}
\endlist
*/
@@ -59,66 +60,99 @@ Tutorial chapters:
\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 common task when extending QML is to provide a new QML type that supports some
+ custom functionality beyond what is provided by the built-in \l {QML Elements}.
+For example, this could be done to implement particular data models, or provide
+elements with custom painting and drawing capabilities, or access system features
+like network programming that are not accessible through built-in QML features.
+
+In this tutorial, we will show how to use the C++ classes in the QtDeclarative
+module to extend QML. The end result will be a simple Pie Chart display implemented by
+several custom QML types connected together through QML features like bindings and
+signals, and made available to the QML runtime through a plugin.
+
+To begin with, let's create a new QML type called "PieChart" that has two properties: a name
+and a color. We will make it available in a \l {Modules}{module} called "Charts", with
a module version of 1.0.
-We want this \c Musician type to be usable from QML like this:
+
+We want this \c PieChart type to be usable from QML like this:
\code
- import Music 1.0
+ import Charts 1.0
- Musician {
- name: "Reddy the Rocker"
- instrument: "Guitar"
+ PieChart {
+ width: 100; height: 100
+ name: "A simple pie chart"
+ color: "red"
}
\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},
+To do this, we need a C++ class that encapsulates this \c PieChart type and its two
+properties. Since QML makes extensive use of 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
+\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:
+Here is our \c PieChart class, defined in \c piechart.h:
-\snippet declarative/tutorials/extending/chapter1-basics/musician.h 0
+\snippet declarative/tutorials/extending/chapter1-basics/piechart.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.
+The class inherits from QDeclarativeItem because we want to override
+QDeclarativeItem::paint() in order to draw. If the class just represented some
+data type and was not an item that actually needed to be displayed, it could simply inherit
+from QObject. Or, if we want to extend the functionality of an existing QObject-based
+class, it could inherit from that class instead.
-Our QML file, \c app.qml, creates a \c Musician item and display the musician's details
+The \c PieChart class defines the two properties, \c name and \c color, with the Q_PROPERTY macro,
+and overrides QDeclarativeItem::paint(). The class implementation in \c piechart.cpp
+simply sets and returns the \c m_name and \c m_color values as appropriate, and
+implements \c paint() to draw a simple pie chart. It also turns off the
+QGraphicsItem::ItemHasNoContents flag to enable painting:
+
+\snippet declarative/tutorials/extending/chapter1-basics/piechart.cpp 0
+\dots 0
+\snippet declarative/tutorials/extending/chapter1-basics/piechart.cpp 1
+
+Now that we have defined the \c PieChart type, we will use it from QML. The \c app.qml
+file creates a \c PieChart item and display the pie chart's details
using a standard QML \l Text item:
\snippet declarative/tutorials/extending/chapter1-basics/app.qml 0
+Notice that although the color is specified as a string in QML, it is automatically
+converted to a QColor object for the PieChart \c color property. Automatic conversions are
+provided for various other \l {QML Basic Types}{basic types}; for example, a string
+like "640x480" can be automatically converted to a QSize value.
+
We'll also create a C++ application that uses a QDeclarativeView to run and
-display \c app.qml. The application must register the \c Musician type
+display \c app.qml. The application must register the \c PieChart type
using the qmlRegisterType() function, to allow it to be used from QML. If
-you don't register the type, \c app.qml won't be able to create a \c Musician.
+you don't register the type, \c app.qml won't be able to create a \c PieChart.
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",
+This call to qmlRegisterType() registers the \c PieChart type as a type called "PieChart", in a module named "Charts",
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.
+Now we can build and run the application:
-\example declarative/tutorials/extending/chapter1-basics
+\image extending-tutorial-chapter1.png
+
+Try it yourself with the code in Qt's \c examples/tutorials/extending/chapter1-basics directory.
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.
+This may seem odd if you're used to running QML files with the \l {QML Viewer}.
Later on, we'll show how to create a plugin so that you can run \c app.qml using the
-\c qml tool instead.
+\l {QML Viewer} instead.
*/
@@ -128,39 +162,40 @@ Later on, we'll show how to create a plugin so that you can run \c app.qml using
\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:
+Suppose we want \c PieChart to have a "clearChart()" method that erases the
+chart and then emits a "chartCleared" signal. Our \c app.qml would be able
+to call \c clearChart() and receive \c chartCleared() signals like this:
\snippet declarative/tutorials/extending/chapter2-methods/app.qml 0
-To do this, we add a \c perform() method and a \c performanceEnded() signal
+\image extending-tutorial-chapter2.png
+
+To do this, we add a \c clearChart() method and a \c chartCleared() signal
to our C++ class:
-\snippet declarative/tutorials/extending/chapter2-methods/musician.h 0
+\snippet declarative/tutorials/extending/chapter2-methods/piechart.h 0
\dots
-\snippet declarative/tutorials/extending/chapter2-methods/musician.h 1
+\snippet declarative/tutorials/extending/chapter2-methods/piechart.h 1
\dots
-\snippet declarative/tutorials/extending/chapter2-methods/musician.h 2
+\snippet declarative/tutorials/extending/chapter2-methods/piechart.h 2
\dots
-\snippet declarative/tutorials/extending/chapter2-methods/musician.h 3
+\snippet declarative/tutorials/extending/chapter2-methods/piechart.h 3
-The use of Q_INVOKABLE makes the \c perform() method available to the
+The use of Q_INVOKABLE makes the \c clearChart() 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():
+The \c clearChart() method simply changes the color to Qt::transparent,
+repaints the chart, then emits the \c chartCleared() signal:
-\snippet declarative/tutorials/extending/chapter2-methods/musician.cpp 0
+\snippet declarative/tutorials/extending/chapter2-methods/piechart.cpp 0
-Now when we run the application and click the window, the application outputs:
+Now when we run the application and click the window, the pie chart
+disappears, and the application outputs:
\code
- "Reddy the Rocker" is playing the "Guitar"
- The performance has now ended
+ The chart has been cleared
\endcode
Try out the example yourself with the updated code in Qt's \c examples/tutorials/extending/chapter2-methods directory.
@@ -174,45 +209,49 @@ Try out the example yourself with the updated code in Qt's \c examples/tutorials
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.
+other elements' values when property values are changed.
-Let's enable property bindings for the \c instrument property. That means
+Let's enable property bindings for the \c color property. That means
if we have code like this:
\snippet declarative/tutorials/extending/chapter3-bindings/app.qml 0
-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:
+\image extending-tutorial-chapter3.png
-\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
+The "color: chartA.color" statement binds the \c color value of
+\c chartB to the \c color of \c chartA.
+Whenever \c chartA's \c color value changes, \c chartB's \c color value
+updates to the same value. When the window is clicked, the \c onClicked
+handler in the MouseArea changes the color of \c chartA, thereby changing
+both charts to the color blue.
-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
+It's easy to enable property binding for the \c color property.
+We add a \l{Qt's Property System}{NOTIFY} feature to its Q_PROPERTY() declaration to indicate that a "colorChanged" signal
is emitted whenever the value changes.
-\snippet declarative/tutorials/extending/chapter3-bindings/musician.h 0
+\snippet declarative/tutorials/extending/chapter3-bindings/piechart.h 0
\dots
-\snippet declarative/tutorials/extending/chapter3-bindings/musician.h 1
+\snippet declarative/tutorials/extending/chapter3-bindings/piechart.h 1
\dots
-\snippet declarative/tutorials/extending/chapter3-bindings/musician.h 2
+\snippet declarative/tutorials/extending/chapter3-bindings/piechart.h 2
\dots
-\snippet declarative/tutorials/extending/chapter3-bindings/musician.h 3
+\snippet declarative/tutorials/extending/chapter3-bindings/piechart.h 3
-Then, we emit this signal in \c setInstrument():
+Then, we emit this signal in \c setPieSlice():
-\snippet declarative/tutorials/extending/chapter3-bindings/musician.cpp 0
+\snippet declarative/tutorials/extending/chapter3-bindings/piechart.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
+It's important for \c setColor() to check that the color value has actually changed
+before emitting \c colorChanged(). This ensures the signal is not emitted unnecessarily and
also prevents loops when other elements respond to the value change.
+The use of bindings is essential to QML. You should always add NOTIFY
+signals for properties if they are able to be implemented, so that your
+properties can be used in bindings. Properties that cannot be bound cannot be
+automatically updated and cannot be used as flexibly in QML. Also, since
+bindings are invoked so often and relied upon in QML usage, users of your
+custom QML types may see unexpected behavior if bindings are not implemented.
+
*/
/*!
@@ -220,19 +259,19 @@ also prevents loops when other elements respond to the value change.
\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:
+The \c PieChart type currently has a string-type property and a color-type property.
+It could have many other types of properties. For example, we could add an
+integer-type property to store an identifier for each pie chart:
\code
- class Musician : public QObject
+ class PieChart : public QDeclarativeItem
{
...
- Q_PROPERTY(int age READ age WRITE setAge)
+ Q_PROPERTY(int id READ id WRITE setId)
public:
...
- int age() const;
- void setAge(int age);
+ int id() const;
+ void setId(int id);
...
};
\endcode
@@ -257,31 +296,39 @@ types:
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:
+For example, let's replace the use of the \c property with a type called
+"PieSlice" that has a \c color property. Instead of assigning a color,
+we assign an \c PieSlice value which itself contains a \c color:
\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml 0
-Like \c Musician, this new \c Instrument type has to inherit from QObject and declare
+Like \c PieChart, this new \c PieSlice type inherits from QDeclarativeItem and declares
its properties with Q_PROPERTY():
-\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.h 0
+\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.h 0
-To use it from \c Musician, we modify the \c instrument property declaration
+To use it in \c PieChart, we modify the \c color property declaration
and associated method signatures:
-\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/musician.h 0
+\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.h 0
\dots
-\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/musician.h 1
+\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.h 1
\dots
-\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/musician.h 2
+\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.h 2
\dots
-\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/musician.h 3
+\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.h 3
+
+There is one thing to be aware of when implementing \c setPieSlice(). The \c PieSlice
+is a visual item, so it must be set as a child of the \c PieChart using
+QDeclarativeItem::setParentItem() so that the \c PieChart knows to paint this child
+item when its contents are drawn:
+
+\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp 0
-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:
+
+Like the \c PieChart type, the \c PieSlice type has to be registered
+using qmlRegisterType() to be used from QML. As with \c PieChart, we'll add the
+type to the "Charts" module, version 1.0:
\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp 0
\dots
@@ -293,16 +340,66 @@ Try it out with the code in Qt's \c examples/tutorials/extending/chapter4-custom
*/
+
+/*!
+\title Chapter 5: Using List Property Types
+
+\example declarative/tutorials/extending/chapter5-listproperties
+
+Right now, a \c PieChart can only have one \c PieSlice. Ideally a chart would
+have multiple slices, with different colors and sizes. To do this, we could
+have a \c slices property that accepts a list of \c PieSlice items:
+
+\snippet declarative/tutorials/extending/chapter5-listproperties/app.qml 0
+
+\image extending-tutorial-chapter5.png
+
+To do this, we replace the \c pieSlice property in \c PieChart with a \c slices property,
+declared as a QDeclarativeListProperty type. The QDeclarativeListProperty class enables the
+creation of list properties in QML extensions. We replace the \c pieSlice()
+function with a \c slices() function that returns a list of slices, and add
+an internal \c append_slice() function (discussed below). We also use a QList to
+store the internal list of slices as \c m_slices:
+
+\snippet declarative/tutorials/extending/chapter5-listproperties/piechart.h 0
+\dots
+\snippet declarative/tutorials/extending/chapter5-listproperties/piechart.h 1
+\dots
+\snippet declarative/tutorials/extending/chapter5-listproperties/piechart.h 2
+
+Although the \c slices property does not have an associated \c WRITE function,
+it is still modifiable because of the way QDeclarativeListProperty works.
+In the \c PieChart implementation, we implement \c PieChart::slices() to
+return a QDeclarativeListProperty value and indicate that the internal
+\c PieChart::append_slice() function is to be called whenever a request is made from QML
+to add items to the list:
+
+\snippet declarative/tutorials/extending/chapter5-listproperties/piechart.cpp 0
+
+The \c append_slice() function simply sets the parent item as before,
+and adds the new item to the \c m_slices list. As you can see, the append function for a
+QDeclarativeListProperty is called with two arguments: the list property, and
+the item that is to be appended.
+
+The \c PieSlice class has also been modified to include \c fromAngle and \c angleSpan
+properties and to draw the slice according to these values. This is a straightforward
+modification if you have read the previous pages in this tutorial, so the code is not shown here.
+
+The complete code can be seen in the updated \c examples/tutorials/extending/chapter5-listproperties directory.
+
+*/
+
+
/*!
-\title Chapter 5: Writing an Extension Plugin
+\title Chapter 6: Writing an Extension Plugin
-\example declarative/tutorials/extending/chapter5-plugins
+\example declarative/tutorials/extending/chapter6-plugins
-Currently the \c Musician and \c Instrument types are used by \c app.qml,
+Currently the \c PieChart and \c PieSlice types are used by \c app.qml,
which is displayed using a QDeclarativeView in a C++ application. An alternative
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
+to the QML engine. This allows \c app.qml to be loaded with the \l {QML Viewer}
+(or some other QML \l{Qt Declarative UI Runtime}{runtime} application) instead of writing a \c main.cpp file and
loading our own C++ application.
To create a plugin library, we need:
@@ -313,45 +410,48 @@ To create a plugin library, we need:
\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
+First, we create a plugin class named \c ChartsPlugin. It subclasses QDeclarativeExtensionPlugin
and registers our QML types in the inherited \l{QDeclarativeExtensionPlugin::}{registerTypes()} method. It also calls
Q_EXPORT_PLUGIN2 for Qt's \l{How to Create Qt Plugins}{plugin system}.
-Here is the \c MusicPlugin definition in \c musicplugin.h:
+Here is the \c ChartsPlugin definition in \c chartsplugin.h:
-\snippet declarative/tutorials/extending/chapter5-plugins/musicplugin.h 0
+\snippet declarative/tutorials/extending/chapter6-plugins/chartsplugin.h 0
-And its implementation in \c musicplugin.cpp:
+And its implementation in \c chartsplugin.cpp:
-\snippet declarative/tutorials/extending/chapter5-plugins/musicplugin.cpp 0
+\snippet declarative/tutorials/extending/chapter6-plugins/chartsplugin.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
+\quotefile declarative/tutorials/extending/chapter6-plugins/chapter6-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
+Here, we specify that a plugin named "chapter6-plugin" (the name
of the example project) can be found in the "lib" subdirectory:
-\quotefile declarative/tutorials/extending/chapter5-plugins/qmldir
+\quotefile declarative/tutorials/extending/chapter6-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:
+the project and then load the QML file in the \l {QML Viewer}:
\code
- qml app.qml
+ qmlviewer app.qml
\endcode
-Notice the "import Music 1.0" statement has disappeared from \c app.qml. This is
+(On Mac OS X, you can launch the "QMLViewer" application instead.)
+
+Notice the "import Charts 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
+having PieChart.qml and PieSlice.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
+\page qml-extending-tutorial7.html
+\title Chapter 7: In Summary
In this tutorial, we've shown the basic steps for creating a QML extension:
@@ -360,47 +460,33 @@ In this tutorial, we've shown the basic steps for creating a QML extension:
\o Add callable methods using Q_INVOKABLE or Qt slots, and connect to Qt signals with an \c onSignal syntax
\o Add property bindings by defining \l{Qt's Property System}{NOTIFY} signals
\o Define custom property types if the built-in types are not sufficient
+\o Define list property types using QDeclarativeListProperty
\o 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:
+QML extensions. For example, we could use \l{Default Property}{default properties} to allow
+slices to be added without using the \c slices property:
\code
- Musician {
- Instrument { type: "Guitar" }
- Instrument { type: "Drums" }
- Instrument { type: "Keyboard" }
+ PieChart {
+ PieSlice { ... }
+ PieSlice { ... }
+ PieSlice { ... }
}
\endcode
-Or even change the \c instrument of a \c Musician from time to time using \l{Property Value Sources}{property value sources}:
+Or randomly add and remove slices from time to time using \l{Property Value Sources}{property value sources}:
\code
- Musician {
- InstrumentRandomizer on instrument {}
+ PieChart {
+ PieSliceRandomizer on slices {}
}
\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 2fd6fa8..3acfbdf 100644
--- a/doc/src/declarative/extending.qdoc
+++ b/doc/src/declarative/extending.qdoc
@@ -704,10 +704,6 @@ of some of the types. For the remaining types the default values are undefined.
\row \o color \o #000000 (black)
\endtable
-If specified, the optional "default" attribute marks the new property as the
-types default property, overriding any existing default property. Using the
-default attribute twice in the same type block is an error.
-
The following example shows how to declare a new "innerColor" property that
controls the color of the inner rectangle.
@@ -725,6 +721,9 @@ controls the color of the inner rectangle.
}
\endcode
+
+\section3 Property signal handlers
+
Adding a property to an item automatically adds a \e{value-changed}
signal handler to the item. The signal hander is named
\c{on<Property_name>Changed}, with the first letter of the property
@@ -743,6 +742,42 @@ example shows how to output to a text console a new value of property
}
\endcode
+
+\section3 Setting default properties
+
+The optional \c default attribute for a property marks it as the \e {default property}
+for a type. This allows other items to specify the default property's value
+as child elements. For example, the \l Item element's default property is its
+\l{Item::children}{children} property. This allows the children of an \l Item
+to be set like this:
+
+\qml
+Item {
+ Rectangle {}
+ Rectangle {}
+}
+\endqml
+
+If the \l{Item::children}{children} property was not the default property for
+\l Item, its value would have to be set like this instead:
+
+\qml
+Item {
+ children: [
+ Rectangle {}
+ Rectangle {}
+ ]
+}
+\endqml
+
+See the \l{declarative/ui-components/tabwidget}{TabWidget} example for a
+demonstration of using default properties.
+
+Specifying a default property overrides any existing default property (for
+example, any default property inherited from a parent item). Using the
+default attribute twice in the same type block is an error.
+
+
\target qml-property-aliases
\section2 Property aliases
diff --git a/doc/src/declarative/focus.qdoc b/doc/src/declarative/focus.qdoc
index cc546c0..0dd5eb3 100644
--- a/doc/src/declarative/focus.qdoc
+++ b/doc/src/declarative/focus.qdoc
@@ -87,7 +87,7 @@ Text {
An \l Item requests focus by setting the \c {Item::focus} property to true.
For very simple cases simply setting the \c {Item::focus} property is sometimes
-sufficient. If we run the following example with the \l {Qt Declarative UI Runtime}{qml} tool, we see that
+sufficient. If we run the following example with the \l {QML Viewer}, we see that
the \c {keyHandler} element has \e {active focus} and pressing the 'A', 'B'
or 'C' keys modifies the text appropriately.
diff --git a/doc/src/declarative/globalobject.qdoc b/doc/src/declarative/globalobject.qdoc
index 36d91ec..a9aee2f 100644
--- a/doc/src/declarative/globalobject.qdoc
+++ b/doc/src/declarative/globalobject.qdoc
@@ -35,7 +35,7 @@ Contains all the properties of the JavaScript global object, plus:
\section1 Qt Object
-The \l{Qt}{Qt object} provides useful enums and functions from Qt, for use in all QML
+The \l{QmlGlobalQtObject}{Qt object} provides useful enums and functions from Qt, for use in all QML
files.
\section1 XMLHttpRequest
diff --git a/doc/src/declarative/modules.qdoc b/doc/src/declarative/modules.qdoc
index 02a2f5f..938222a 100644
--- a/doc/src/declarative/modules.qdoc
+++ b/doc/src/declarative/modules.qdoc
@@ -72,7 +72,7 @@ The second exception is explained in more detail in the section below on Namespa
\section2 The Import Path
Installed modules are searched for on the import path.
-The \c -I option to the \l {Qt Declarative UI Runtime}{qml} runtime adds paths to the import path.
+The \c -I option to the \l {QML Viewer} adds paths to the import path.
From C++, the path is available via \l QDeclarativeEngine::importPathList() and can be prepended to
using \l QDeclarativeEngine::addImportPath().
@@ -103,9 +103,16 @@ the \c qmldir file. Types which you do not wish to export to users of your modul
may be marked with the \c internal keyword: \c internal <TypeName> <File>.
The same type can be provided by different files in different versions, in which
-case later earlier versions (eg. 1.2) must precede earlier versions (eg. 1.0),
+case later versions (eg. 1.2) must precede earlier versions (eg. 1.0),
since the \e first name-version match is used and a request for a version of a type
-can be fulfilled by one defined in an earlier version of the module.
+can be fulfilled by one defined in an earlier version of the module. If a user attempts
+to import a version earlier than the earliest provided or later than the latest provided,
+an error results, but if the user imports a version within the range of versions provided,
+even if no type is specific to that version, no error results.
+
+A single module, in all versions, may only be provided in a single directory (and a single \c qmldir file).
+If multiple are provided, only the first in the search path will be used (regardless of whether other versions
+are provided by directories later in the search path).
Installed and remote files without a namespace \e must be referred to by version information described above,
local files \e may have it.
@@ -122,7 +129,7 @@ to the module.
of the plugin binary, which is platform dependent; e.g. the library MyAppTypes would produce
a libMyAppTypes.so on Linux and MyAppTypes.dll on Windows.
By default the engine searches for the plugin library in the directory containing the \c qmldir
-file. The \c -P option to the \l {Qt Declarative UI Runtime}{qml} runtime adds paths to the
+file. The \c -P option to the \l {QML Viewer} adds paths to the
plugin search path.
From C++, the path is available via \l QDeclarativeEngine::pluginPathList() and can be prepended to
using \l QDeclarativeEngine::addPluginPath().
diff --git a/doc/src/declarative/network.qdoc b/doc/src/declarative/network.qdoc
index b0d19e2..60359de 100644
--- a/doc/src/declarative/network.qdoc
+++ b/doc/src/declarative/network.qdoc
@@ -54,7 +54,7 @@ Network transparency is supported throughout QML, for example:
\o WebViews - the \c url property of WebView (obviously!)
\endlist
-Even QML types themselves can be on the network - if the \l {Qt Declarative UI Runtime}{qml} tool is used to load
+Even QML types themselves can be on the network - if the \l {QML Viewer} is used to load
\tt http://example.com/mystuff/Hello.qml and that content refers to a type "World", the engine
will load \tt http://example.com/mystuff/qmldir and resolve the type just as it would for a local file.
For example if the qmldir file contains the line "World World.qml", it will load
@@ -119,7 +119,7 @@ All network access from QML is managed by a QNetworkAccessManager set on the QDe
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
+For example, the \l {QML Viewer} 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.
diff --git a/doc/src/declarative/pics/extending-tutorial-chapter1.png b/doc/src/declarative/pics/extending-tutorial-chapter1.png
new file mode 100644
index 0000000..9f5836b
--- /dev/null
+++ b/doc/src/declarative/pics/extending-tutorial-chapter1.png
Binary files differ
diff --git a/doc/src/declarative/pics/extending-tutorial-chapter2.png b/doc/src/declarative/pics/extending-tutorial-chapter2.png
new file mode 100644
index 0000000..5c8f222
--- /dev/null
+++ b/doc/src/declarative/pics/extending-tutorial-chapter2.png
Binary files differ
diff --git a/doc/src/declarative/pics/extending-tutorial-chapter3.png b/doc/src/declarative/pics/extending-tutorial-chapter3.png
new file mode 100644
index 0000000..825553f
--- /dev/null
+++ b/doc/src/declarative/pics/extending-tutorial-chapter3.png
Binary files differ
diff --git a/doc/src/declarative/pics/extending-tutorial-chapter5.png b/doc/src/declarative/pics/extending-tutorial-chapter5.png
new file mode 100644
index 0000000..0c2e69e
--- /dev/null
+++ b/doc/src/declarative/pics/extending-tutorial-chapter5.png
Binary files differ
diff --git a/doc/src/declarative/pics/imageprovider.png b/doc/src/declarative/pics/imageprovider.png
new file mode 100644
index 0000000..422103c
--- /dev/null
+++ b/doc/src/declarative/pics/imageprovider.png
Binary files differ
diff --git a/doc/src/declarative/qdeclarativedebugging.qdoc b/doc/src/declarative/qdeclarativedebugging.qdoc
index da6e407..ea21852 100644
--- a/doc/src/declarative/qdeclarativedebugging.qdoc
+++ b/doc/src/declarative/qdeclarativedebugging.qdoc
@@ -47,7 +47,7 @@ Rectangle {
When a transition doesn't look quite right, it can be helpful to view it in slow
motion to see what is happening more clearly. This functionality is supported
-in the \l {Qt Declarative UI Runtime}{qmlviewer} tool: to enable this,
+in the \l {QML Viewer} tool: to enable this,
click on the "Debugging" menu, then "Slow Down Animations".
@@ -64,7 +64,7 @@ import Qt 4.7
Rectangle { width: 100; height: 100 }
\endqml
-If you set \c {QML_IMPORT_TRACE=1} before running the \l {Qt Declarative UI Runtime}{qmlviewer}
+If you set \c {QML_IMPORT_TRACE=1} before running the \l {QML Viewer}
(or your QML C++ application), you will see output similar to this:
\code
@@ -85,11 +85,11 @@ show QML debugging information and options for your application, including
object inspection, property monitoring and application frame-rate analysis.
Creator can be used to debug both local and remote QML applications. To
-enable remote debugging, start the \l {Qt Declarative UI Runtime}{qml} tool
+enable remote debugging, start the \l {QML Viewer}
on the remote device with a debugging port defined, like this:
\code
- QML_DEBUG_SERVER_PORT=3768 qml myqmlfile.qml
+ QML_DEBUG_SERVER_PORT=3768 qmlviewer myqmlfile.qml
\endcode
In Creator, open the project settings pane and set the server and port
diff --git a/doc/src/declarative/qdeclarativei18n.qdoc b/doc/src/declarative/qdeclarativei18n.qdoc
index 40f7919..b6e6c6e 100644
--- a/doc/src/declarative/qdeclarativei18n.qdoc
+++ b/doc/src/declarative/qdeclarativei18n.qdoc
@@ -49,7 +49,7 @@ capabilities are described more fully in:
\o \l {Qt Linguist Manual}
\endlist
-You can test a translation with the \l {Qt Declarative UI Runtime}{qml} tool using the -translation option.
+You can test a translation with the \l {QML Viewer} using the -translation option.
\section1 Example
@@ -61,8 +61,8 @@ hello.qml:
import Qt 4.7
Rectangle {
- width: 200; height: 200
- Text { text: qsTr("Hello"); anchors.centerIn: parent }
+ width: 200; height: 200
+ Text { text: qsTr("Hello"); anchors.centerIn: parent }
}
\endqml
@@ -76,7 +76,7 @@ a translation and create the release file \c hello.qm.
Finally, we can test the translation:
\code
-qml -translation hello.qm hello.qml
+qmlviewer -translation hello.qm hello.qml
\endcode
diff --git a/doc/src/declarative/qdeclarativeperformance.qdoc b/doc/src/declarative/qdeclarativeperformance.qdoc
index 26c1e89..be8c029 100644
--- a/doc/src/declarative/qdeclarativeperformance.qdoc
+++ b/doc/src/declarative/qdeclarativeperformance.qdoc
@@ -115,4 +115,25 @@ provide an image that includes the frame and the shadow.
Avoid running JavaScript during animation. For example, running a complex
JavaScript expression for each frame of an x property animation.
+\section1 Rendering
+
+Often using a different graphics system will give superior performance to the native
+graphics system (this is especially the case on X11). This can be configured using
+QApplication::setGraphicsSystem() or via the command line using the \c -graphicssystem
+switch.
+
+You can enable OpenGL acceleration using the \c opengl graphics system, or by setting a
+QGLWidget as the viewport of your QDeclarativeView.
+
+You may need to try various options to find what works the best for your application.
+For embedded X11-based devices one recommended combination is to use the raster graphics
+system with a QGLWidget for the viewport. While this doesn't guarantee the \bold fastest
+performance for all use-cases, it typically has \bold{consistently good} performance for
+all use-cases. In contrast, only using the raster paint engine may result in very good
+performance for parts of your application and very poor performance elsewhere.
+
+The QML Viewer uses the raster graphics system by default for X11 and OS X. It also
+includes a \c -opengl command line option which sets a QGLWidget as the viewport of the
+view. On OS X, a QGLWidget is always used.
+
*/
diff --git a/doc/src/declarative/qml-intro.qdoc b/doc/src/declarative/qml-intro.qdoc
index ac79496..fbab001 100644
--- a/doc/src/declarative/qml-intro.qdoc
+++ b/doc/src/declarative/qml-intro.qdoc
@@ -105,9 +105,17 @@ This is a valid QML script. To run it, copy it and save it to a file, say
myexample.qml, and on the command line run the command
\code
- qml myexample.qml
+ qmlviewer myexample.qml
\endcode
+On Mac OS X, open the "QMLViewer" application instead and open the
+\c myexample.qml file, or run it from the command line:
+
+ \code
+ QMLViewer.app/Contents/MacOS/QMLViewer myexample.qml
+ \endcode
+
+
It will create a very boring rectangle in its own window.
@@ -915,16 +923,18 @@ the rotation of the needle image. Notice this piece of code in Dial where
the change in \c value modifies the position of the needle.
\code
- SpringFollow on angle {
- spring: 1.4
- damping: .15
- to: Math.min(Math.max(-130, root.value*2.6 - 130), 133)
+ angle: Math.min(Math.max(-130, root.value*2.6 - 130), 133)
+ Behavior on angle {
+ SpringAnimation {
+ spring: 1.4
+ damping: .15
+ }
}
\endcode
This is part of the \c needleRotation that rotates the needle and causes the
-rotation of its shadow. \l SpringFollow is an element that modifies the value
-of that rotation angle \e to and mimics the oscillatory behavior of a spring,
+rotation of its shadow. \l SpringAnimation is an element that modifies the value
+of that rotation \e angle and mimics the oscillatory behavior of a spring,
with the appropriate \e spring constant to control the acceleration and the \e
damping to control how quickly the effect dies away.
diff --git a/doc/src/declarative/qmlviewer.qdoc b/doc/src/declarative/qmlviewer.qdoc
index efff9cc..5efc0ce 100644
--- a/doc/src/declarative/qmlviewer.qdoc
+++ b/doc/src/declarative/qmlviewer.qdoc
@@ -42,7 +42,7 @@ deployment of QML applications. In those cases, the QML runtime should be invoke
from a Qt application instead; see \l {Qt Declarative UI Runtime} for more
information.
-The viewer is located at QTDIR/bin/qmlviewer. To load a \c .qml file
+The viewer is located at \c QTDIR/bin/qmlviewer. To load a \c .qml file
with the viewer, run the viewer and select the file to be opened, or provide the
file path on the command line:
@@ -50,7 +50,7 @@ file path on the command line:
qmlviewer myqmlfile.qml
\endcode
-On Mac OS X, the QML Viewer application is named \c QMLViewer.app instead. You
+On Mac OS X, the QML Viewer application is named "QMLViewer" instead. You
can launch the viewer by opening the QMLViewer application from the Finder, or
from the command line:
diff --git a/doc/src/declarative/qtprogrammers.qdoc b/doc/src/declarative/qtprogrammers.qdoc
index ae54d58..68d56bf 100644
--- a/doc/src/declarative/qtprogrammers.qdoc
+++ b/doc/src/declarative/qtprogrammers.qdoc
@@ -27,8 +27,6 @@
/*!
- INCOMPLETE
-
\page qtprogrammers.html
\target qtprogrammers
\title QML for Qt programmers
@@ -146,4 +144,14 @@ transition from an arbitrary Text item, or characters within a Text item, so you
item would need to be sufficiently flexible to allow such animation.
\section1 QML Items Compared With QGraphicsWidgets
+
+The main difference between QML items and QGraphicsWidgets is how they are intended to be used. The technical implementation details are much the same, but in practice they are different because QML items are made for declarative and compositional use, and QGraphicsWidgets are made for imperative and more integrated use. Both QML items and QGraphicsWidgets inherit from QGraphicsObject, and can co-exist. The differences are in the layouting system and the interfacing with other components. Note that, as QGraphicsWidgets tend more to be all-in-one packages, the equivalent of a QGraphicsWidget may be many QML items composed across several QML files, but it can still be loaded and used as a single QGraphicsObject from C++.
+
+QGraphicsWidgets are usually designed to be laid out with QGraphicsLayouts. QML does not use QGraphicsLayouts, as the Qt layouts do not mix well with animated and fluid UIs, so the geometry interface is one of the main differences. When writing QML elements, you allow the designers to place their bounding rectangle using absolute geometry, bindings or anchors (all setup for you when you inherit QDeclarativeItem) and you do not use layouts or size hints. If size hints are appropriate, then place them in the QML documentation so that the designers know how to use the item best, but still have complete control over the look and feel.
+
+The other main difference is that QGraphicsWidgets tend to follow the widget model, in that they are a self-contained bundle of UI and logic. In contrast, QML primitives are usually a single purpose item that does not fulfill a use case on its own, but is composed into the equivalent of the widget inside the QML file. So when writing QML Items, try to avoid doing UI logic or composing visual elements inside the items. Try instead to write more general purpose primitives, so that the look and feel (which involves the UI logic) can be written in QML.
+
+Both differences are caused by the different method of interaction. QGraphicsWidget is a QGraphicsObject subclass which makes fluid UI development from C++ easier, and QDeclarativeItem is a QGraphicsObject subclass which makes fluid UI development from QML easier. The difference therefore is primarily one of the interface exposed, and the design of the items that come with it (the Declarative primitives for QML and the nothing for QGraphicsWidget, because you need to write your own UI logic into the subclass).
+
+If you wish to use both QML and C++ to write the UI, for example to ease the transition period, it is recommended to use QDeclarativeItem subclasses (although you can use QGraphicsWidgets as well). To allow for easier use from C++ make the root item of each C++ component a LayoutItem, and load individual 'widgets' of QML (possibly comprised of multiple files, and containing a self-contained bundle of UI and logic) into your scene to replace individual QGraphicsWidgets one at a time.
*/
diff --git a/doc/src/declarative/tutorial.qdoc b/doc/src/declarative/tutorial.qdoc
index c884486..7a97eb1 100644
--- a/doc/src/declarative/tutorial.qdoc
+++ b/doc/src/declarative/tutorial.qdoc
@@ -101,11 +101,11 @@ The \c font.pointSize and \c font.bold properties are related to fonts and use t
\section2 Viewing the example
-To view what you have created, run the \l{Qt Declarative UI Runtime}{qml} tool (located in the \c bin directory) with your filename as the first argument.
+To view what you have created, run the \l{QML Viewer} tool (located in the \c bin directory) with your filename as the first argument.
For example, to run the provided completed Tutorial 1 example from the install location, you would type:
\code
-bin/qml $QTDIR/examples/declarative/tutorials/helloworld/tutorial1.qml
+bin/qmlviewer $QTDIR/examples/declarative/tutorials/helloworld/tutorial1.qml
\endcode
*/