aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2011-05-31 15:25:44 +1000
committerMartin Jones <martin.jones@nokia.com>2011-05-31 15:25:44 +1000
commit766521d62a4cf4598326a510186b080a91bde6dd (patch)
tree5cf89c1338f42122c370c649b73c8193ca079268 /doc
parenta91b8a041966f8aea4bf01fdcb1d5006547f3902 (diff)
parente7fef9d6115d1a9193c112d8fd4249ae9396dae3 (diff)
Merge branch 'qtquick2'
Conflicts: demos/declarative/flickr/common/Progress.qml demos/declarative/flickr/common/RssModel.qml demos/declarative/flickr/common/ScrollBar.qml demos/declarative/flickr/common/Slider.qml demos/declarative/flickr/mobile/Button.qml demos/declarative/flickr/mobile/GridDelegate.qml demos/declarative/flickr/mobile/ImageDetails.qml demos/declarative/flickr/mobile/ListDelegate.qml demos/declarative/flickr/mobile/TitleBar.qml demos/declarative/flickr/mobile/ToolBar.qml demos/declarative/webbrowser/content/Button.qml demos/declarative/webbrowser/content/FlickableWebView.qml demos/declarative/webbrowser/content/Header.qml demos/declarative/webbrowser/content/ScrollBar.qml demos/declarative/webbrowser/content/UrlInput.qml demos/declarative/webbrowser/webbrowser.qml doc/src/snippets/declarative/mousearea/mousearea-snippet.qml examples/declarative/modelviews/webview/newwindows/qml/alerts.html examples/declarative/modelviews/webview/newwindows/qml/content/Mapping/map.html examples/declarative/modelviews/webview/newwindows/qml/content/pics/cancel.png examples/declarative/modelviews/webview/newwindows/qml/content/pics/ok.png examples/declarative/modelviews/webview/newwindows/qml/newwindows.html src/declarative/graphicsitems/qdeclarativetextinput.cpp src/declarative/qml/qdeclarativecompiledbindings.cpp src/declarative/qml/qdeclarativecompiledbindings_p.h src/declarative/qml/qdeclarativedom.cpp src/declarative/qml/qdeclarativedom_p.h src/declarative/qml/qdeclarativedom_p_p.h src/declarative/qml/qdeclarativeengine.cpp src/declarative/qml/qdeclarativetypeloader.cpp src/imports/particles/particles.cpp tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp tests/auto/declarative/qmlvisual/qdeclarativeflickable/data/flickable-horizontal.4.png tests/auto/declarative/qmlvisual/qdeclarativepathview/data/test-pathview.6.png tests/auto/declarative/qmlvisual/qdeclarativepositioners/data/usingRepeater.0.png tests/auto/declarative/qmlvisual/qdeclarativespringanimation/data/follow.0.png tests/auto/declarative/qmlvisual/qdeclarativespringanimation/data/follow.1.png tests/auto/declarative/qmlvisual/qdeclarativespringanimation/data/follow.2.png tests/auto/declarative/qmlvisual/qdeclarativespringanimation/data/follow.3.png tests/auto/declarative/qmlvisual/qdeclarativespringanimation/data/follow.4.png tests/auto/declarative/qmlvisual/qdeclarativespringanimation/data/follow.5.png tests/auto/declarative/qmlvisual/qdeclarativespringanimation/data/follow.6.png tests/auto/declarative/qmlvisual/qdeclarativespringanimation/data/follow.7.png tests/auto/declarative/qmlvisual/qdeclarativetext/align/data-MAC/multilineAlign.0.png tests/auto/declarative/qmlvisual/qdeclarativetext/align/data-X11/multilineAlign.0.png tests/auto/declarative/qmlvisual/qdeclarativetext/baseline/data-X11/parentanchor.0.png tests/auto/declarative/qmlvisual/qdeclarativetext/data-MAC/qtbug_14865.0.png tests/auto/declarative/qmlvisual/qdeclarativetext/data-MAC/qtbug_14865.1.png tests/auto/declarative/qmlvisual/qdeclarativetext/data-X11/qtbug_14865.0.png tests/auto/declarative/qmlvisual/qdeclarativetext/data-X11/qtbug_14865.1.png tests/auto/declarative/qmlvisual/qdeclarativetext/elide/data-X11/elide.1.png tests/auto/declarative/qmlvisual/qdeclarativetext/elide/data-X11/elide2.0.png tests/auto/declarative/qmlvisual/qdeclarativetext/elide/data-X11/elide2.1.png tests/auto/declarative/qmlvisual/qdeclarativetext/elide/data-X11/multilength.1.png tests/auto/declarative/qmlvisual/qdeclarativetext/elide/data-X11/multilength.2.png tests/auto/declarative/qmlvisual/qdeclarativetext/elide/data-X11/multilength.3.png tests/auto/declarative/qmlvisual/qdeclarativetext/elide/data-X11/multilength.4.png tests/auto/declarative/qmlvisual/qdeclarativetext/elide/data-X11/multilength.5.png tests/auto/declarative/qmlvisual/qdeclarativetext/font/data-MAC/plaintext2.0.png tests/auto/declarative/qmlvisual/qdeclarativetext/font/data-MAC/plaintext3.0.png tests/auto/declarative/qmlvisual/qdeclarativetext/font/data-X11/plaintext.0.png tests/auto/declarative/qmlvisual/qdeclarativetext/font/data-X11/plaintext2.0.png tests/auto/declarative/qmlvisual/qdeclarativetext/font/data-X11/richtext.0.png tests/auto/declarative/qmlvisual/qdeclarativetext/font/data-X11/richtext2.0.png tests/auto/declarative/qmlvisual/qdeclarativetextedit/data-MAC/usingMultilineEdit.0.png tests/auto/declarative/qmlvisual/qdeclarativetextedit/data-MAC/usingMultilineEdit.1.png tests/auto/declarative/qmlvisual/qdeclarativetextedit/data-MAC/usingMultilineEdit.10.png tests/auto/declarative/qmlvisual/qdeclarativetextedit/data-MAC/usingMultilineEdit.11.png tests/auto/declarative/qmlvisual/qdeclarativetextedit/data-MAC/usingMultilineEdit.2.png tests/auto/declarative/qmlvisual/qdeclarativetextedit/data-MAC/usingMultilineEdit.3.png tests/auto/declarative/qmlvisual/qdeclarativetextedit/data-MAC/usingMultilineEdit.4.png tests/auto/declarative/qmlvisual/qdeclarativetextedit/data-MAC/usingMultilineEdit.5.png tests/auto/declarative/qmlvisual/qdeclarativetextedit/data-MAC/usingMultilineEdit.6.png tests/auto/declarative/qmlvisual/qdeclarativetextedit/data-MAC/usingMultilineEdit.7.png tests/auto/declarative/qmlvisual/qdeclarativetextedit/data-MAC/usingMultilineEdit.8.png tests/auto/declarative/qmlvisual/qdeclarativetextedit/data-MAC/usingMultilineEdit.9.png tests/auto/declarative/qmlvisual/qdeclarativetextedit/data-MAC/wrap.0.png tests/auto/declarative/qmlvisual/qdeclarativetextedit/data-MAC/wrap.1.png tests/auto/declarative/qmlvisual/qdeclarativetextedit/data-MAC/wrap.2.png tests/auto/declarative/qmlvisual/qdeclarativetextedit/data-MAC/wrap.3.png tests/auto/declarative/qmlvisual/qdeclarativetextedit/data-MAC/wrap.4.png tests/auto/declarative/qmlvisual/qdeclarativetextedit/data-MAC/wrap.5.png tests/auto/declarative/qmlvisual/qdeclarativetextedit/data-MAC/wrap.6.png tests/auto/declarative/qmlvisual/qdeclarativetextedit/data-X11/qt-669.0.png tests/auto/declarative/qmlvisual/qdeclarativetextedit/data-X11/qt-669.1.png tests/auto/declarative/qmlvisual/qdeclarativetextedit/data-X11/qt-669.2.png tests/auto/declarative/qmlvisual/qdeclarativetextedit/data-X11/qt-669.3.png tests/auto/declarative/qmlvisual/qdeclarativetextedit/data-X11/qt-669.4.png tests/auto/declarative/qmlvisual/qdeclarativetextedit/data-X11/usingMultilineEdit.10.png tests/auto/declarative/qmlvisual/qdeclarativetextedit/data-X11/usingMultilineEdit.11.png tests/auto/declarative/qmlvisual/qdeclarativetextedit/data-X11/usingMultilineEdit.12.png tests/auto/declarative/qmlvisual/qdeclarativetextedit/data-X11/usingMultilineEdit.7.png tests/auto/declarative/qmlvisual/qdeclarativetextedit/data-X11/usingMultilineEdit.9.png tests/auto/declarative/qmlvisual/qdeclarativetextedit/data-X11/wrap.7.png tests/auto/declarative/qmlvisual/qdeclarativetextinput/data-MAC/echoMode.0.png tests/auto/declarative/qmlvisual/qdeclarativetextinput/data-MAC/echoMode.1.png tests/auto/declarative/qmlvisual/qdeclarativetextinput/data-MAC/echoMode.2.png tests/auto/declarative/qmlvisual/qdeclarativetextinput/data-X11/usingLineEdit.11.png tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp Change-Id: I40df8a9403a58a6c03a0f1734f16a5cbed6c85ff
Diffstat (limited to 'doc')
-rw-r--r--doc/src/declarative/anchor-layout.qdoc4
-rw-r--r--doc/src/declarative/basictypes.qdoc15
-rw-r--r--doc/src/declarative/example-textballoons.qdoc104
-rw-r--r--doc/src/declarative/examples.qdoc4
-rw-r--r--doc/src/declarative/globalobject.qdoc2
-rw-r--r--doc/src/declarative/javascriptblocks.qdoc229
-rw-r--r--doc/src/declarative/modules.qdoc123
-rw-r--r--doc/src/declarative/qdeclarativeintro.qdoc8
-rw-r--r--doc/src/declarative/qmltest.qdoc123
-rw-r--r--doc/src/declarative/whatsnew.qdoc6
-rw-r--r--doc/src/images/declarative-gridmesh.pngbin0 -> 9349 bytes
-rw-r--r--doc/src/images/declarative-shadereffectitem.pngbin0 -> 6557 bytes
-rw-r--r--doc/src/images/declarative-shadereffectsource.pngbin0 -> 1133 bytes
-rw-r--r--doc/src/images/declarative-textballoons_example.pngbin0 -> 29663 bytes
-rw-r--r--doc/src/snippets/declarative/codingconventions/myscript.js9
-rw-r--r--doc/src/snippets/declarative/focus/MyClickableWidget.qml (renamed from doc/src/snippets/declarative/focus/myclickablewidget.qml)0
-rw-r--r--doc/src/snippets/declarative/focus/MyWidget.qml (renamed from doc/src/snippets/declarative/focus/mywidget.qml)0
-rw-r--r--doc/src/snippets/declarative/models/views-models-delegates.qml1
-rw-r--r--doc/src/snippets/declarative/models/visual-model-and-view.qml1
-rw-r--r--doc/src/snippets/declarative/righttoleft/Child.qml (renamed from doc/src/snippets/declarative/webview/webview.qml)20
-rw-r--r--doc/src/snippets/declarative/states/statechangescript.qml1
21 files changed, 637 insertions, 13 deletions
diff --git a/doc/src/declarative/anchor-layout.qdoc b/doc/src/declarative/anchor-layout.qdoc
index 41b04e88c8..a84abf436b 100644
--- a/doc/src/declarative/anchor-layout.qdoc
+++ b/doc/src/declarative/anchor-layout.qdoc
@@ -136,7 +136,9 @@ or anchors its left and right edges but additionally sets a \l {Item::}{width},
result is undefined, as it would not be clear whether the item should use anchoring or absolute
positioning. The same can be said for setting an item's \l {Item::}{y} and \l {Item::}{height}
with \l {Item::}{anchors.top} and \l {Item::}{anchors.bottom}, or setting \l {Item::}{anchors.fill}
-as well as \l {Item::}{width} or \l {Item::}{height}. If you wish to change from using
+as well as \l {Item::}{width} or \l {Item::}{height}. The same applies when using positioners
+such as Row and Grid, which may set the item's \l {Item::}{x} and \l {Item::}{y} properties.
+If you wish to change from using
anchor-based to absolute positioning, you can clear an anchor value by setting it to \c undefined.
*/
diff --git a/doc/src/declarative/basictypes.qdoc b/doc/src/declarative/basictypes.qdoc
index 0e8056a19a..1c412db143 100644
--- a/doc/src/declarative/basictypes.qdoc
+++ b/doc/src/declarative/basictypes.qdoc
@@ -439,7 +439,20 @@
}
\endqml
- The \c variant type can also hold:
+ A \c variant type property can also hold an image or pixmap.
+ A \c variant which contains a QPixmap or QImage is known as a
+ "scarce resource" and the declarative engine will attempt to
+ automatically release such resources after evaluation of any JavaScript
+ expression which requires one to be copied has completed.
+
+ Clients may explicitly release such a scarce resource by calling the
+ "destroy" method on the \c variant property from within JavaScript. They
+ may also explicitly preserve the scarce resource by calling the
+ "preserve" method on the \c variant property from within JavaScript.
+ For more information regarding the usage of a scarce resource, please
+ see \l{Scarce Resources in JavaScript}.
+
+ Finally, the \c variant type can also hold:
\list
\o An array of \l {QML Basic Types}{basic type} values
diff --git a/doc/src/declarative/example-textballoons.qdoc b/doc/src/declarative/example-textballoons.qdoc
new file mode 100644
index 0000000000..90de999265
--- /dev/null
+++ b/doc/src/declarative/example-textballoons.qdoc
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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:FDL$
+** 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 Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of this
+** file.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \title Scenegraph Painted Item Example
+ \example declarative/painteditem/textballoons
+
+ The Painted Item example shows how to use the QML Scene Graph framework to
+ implement custom scenegraph items using QPainter.
+
+ \image declarative-textballoons_example.png
+
+ The QSGPaintedItem class is a class derived from QSGItem for implementing
+ custom QML Scene Graph items using the QPainter interfaces.
+
+ The example consists of an item class, a plugin class and a QML file
+ to use this plugin. The \c TextBalloon class represents the individual
+ text balloons extending QSGPaintedItem, the \c TextBalloonPlugin class
+ represents the skeleton code for a QtQuick plugin and the
+ \c textballoons.qml file is used to load the plugin and display the text
+ balloons.
+
+ We will focus on the \c TextBalloon class first and continue with the
+ \c textballoons.qml file. For an example on how to implement a QtQuick
+ plugin please look at \l{declarative/tutorials/extending/chapter6-plugins}
+ {Writing an Extension Plugin}
+
+ \section1 TextBalloon Class Declaration
+
+ The \c TextBalloon class inherits from QSGPaintedItem. QSGPaintedItem class
+ is the base class for all QPainter based items in the QML Scene Graph
+ framework.
+
+ \snippet examples/declarative/painteditem/textballoons/textballoonplugin/textballoon.h 0
+
+ To implement a QSGPaintedItem you must implement QSGPaintedIem's pure
+ virtual function \l {QSGPaintedItem::}{paint()} which implements the
+ painting of the element.
+
+ \section1 TextBalloon Class Definition
+
+ We have to be sure to initialize the rightAligned property for a
+ TextBalloon item.
+
+ \snippet examples/declarative/painteditem/textballoons/textballoonplugin/textballoon.cpp 0
+
+ Then we implement the \c paint() function which is automatically called by
+ the Scenegraph framework to paint the contents of the item. The function
+ paints the item in local coordinates.
+
+ \snippet examples/declarative/painteditem/textballoons/textballoonplugin/textballoon.cpp 1
+
+ We start with setting the pen and brush on the item to define the look of
+ the item. After that we start drawing. Note that the \l {QSGPaintedItem::}{boundingRect()}
+ item is called to draw depending on the size of the item. The rectangle
+ returned by the \l {QSGPaintedItem::}{boundingRect()} function is the size
+ of the item as defined in the QML file.
+
+ \section1 textballoons.qml file
+
+ The Interface consists of two main parts. The scrollable area with the
+ textballoons and the controls button to add new balloons.
+
+ \section2 BalloonView
+
+ \snippet examples/declarative/painteditem/textballoons/textballoons.qml 0
+
+ The balloonModel contains two elements at application start which will be
+ displayed by the balloonView. The balloonView alernates the TextBalloon
+ delegate items between left-aligned and right-aligned.
+
+ \section2 Controls
+
+ \snippet examples/declarative/painteditem/textballoons/textballoons.qml 1
+
+ The controls part of the UI contains a rectangle with a MouseArea which
+ changes color when the mouse hovers over it. This control 'button' adds
+ a new element to the end of the model with a random width.
+
+ */
diff --git a/doc/src/declarative/examples.qdoc b/doc/src/declarative/examples.qdoc
index 0e325e2f38..c3a6c313aa 100644
--- a/doc/src/declarative/examples.qdoc
+++ b/doc/src/declarative/examples.qdoc
@@ -229,6 +229,10 @@ The examples can be found in Qt's \c examples/declarative directory.
\o \l{declarative/cppextensions/networkaccessmanagerfactory}{Network access manager factory}
\endlist
+\section2 Scenegraph
+\list
+\o \l{declarative/painteditem/textballoons}{Painted Item}
+\endlist
\section1 Labs
diff --git a/doc/src/declarative/globalobject.qdoc b/doc/src/declarative/globalobject.qdoc
index ac2738fe51..4b8b538a65 100644
--- a/doc/src/declarative/globalobject.qdoc
+++ b/doc/src/declarative/globalobject.qdoc
@@ -128,6 +128,8 @@ These databases are user-specific and QML-specific, but accessible to all QML ap
They are stored in the \c Databases subdirectory
of QDeclarativeEngine::offlineStoragePath(), currently as SQLite databases.
+Database connections are automatically closed during Javascript garbage collection.
+
The API can be used from JavaScript functions in your QML:
\snippet declarative/sqllocalstorage/hello.qml 0
diff --git a/doc/src/declarative/javascriptblocks.qdoc b/doc/src/declarative/javascriptblocks.qdoc
index 9501c9d2bc..01d0d45a2d 100644
--- a/doc/src/declarative/javascriptblocks.qdoc
+++ b/doc/src/declarative/javascriptblocks.qdoc
@@ -168,6 +168,44 @@ Notice that calling \l {QML:Qt::include()}{Qt.include()} imports all functions f
\c factorial.js into the \c MyScript namespace, which means the QML component can also
access \c factorial() directly as \c MyScript.factorial().
+In QtQuick 2.0, support has been added to allow JavaScript files to import other
+JavaScript files and also QML modules using a variation of the standard QML import
+syntax (where all of the previously described rules and qualifications apply).
+
+A JavaScript file may import another in the following fashion:
+\code
+.import "filename.js" as UniqueQualifier
+\endcode
+For example:
+\code
+.import "factorial.js" as MathFunctions
+\endcode
+
+A JavaScript file may import a QML module in the following fashion:
+\code
+.import Module.Name MajorVersion.MinorVersion as UniqueQualifier
+\endcode
+For example:
+\code
+.import Qt.test 1.0 as JsQtTest
+\endcode
+In particular, this may be useful in order to access functionality provided
+via a module API; see qmlRegisterModuleApi() for more information.
+
+Due to the ability of a JavaScript file to import another script or QML module in
+this fashion in QtQuick 2.0, some extra semantics are defined:
+\list
+\o a script with imports will not inherit imports from the QML file which imported it (so accessing Component.error will fail, for example)
+\o a script without imports will inherit imports from the QML file which imported it (so accessing Component.error will succeed, for example)
+\o a shared script (i.e., defined as .pragma library) does not inherit imports from any QML file even if it imports no other scripts
+\endlist
+
+The first semantic is conceptually correct, given that a particular script
+might be imported by any number of QML files. The second semantic is retained
+for the purposes of backwards-compatibility. The third semantic remains
+unchanged from the current semantics for shared scripts, but is clarified here
+in respect to the newly possible case (where the script imports other scripts
+or modules).
\section1 Running JavaScript at Startup
@@ -321,4 +359,195 @@ Item {
\endlist
+\section1 Scarce Resources in JavaScript
+
+As described in the documentation for \l{QML Basic Types}, a \c variant type
+property may hold a "scarce resource" (image or pixmap). There are several
+important semantics of scarce resources which should be noted:
+
+\list
+\o By default, a scarce resource is automatically released by the declarative engine as soon as evaluation of the expression in which the scarce resource is allocated is complete if there are no other references to the resource
+\o A client may explicitly preserve a scarce resource, which will ensure that the resource will not be released until all references to the resource are released and the JavaScript engine runs its garbage collector
+\o A client may explicitly destroy a scarce resource, which will immediately release the resource
+\endlist
+
+In most cases, allowing the engine to automatically release the resource is
+the correct choice. In some cases, however, this may result in an invalid
+variant being returned from a function in JavaScript, and in those cases it
+may be necessary for clients to manually preserve or destroy resources for
+themselves.
+
+For the following examples, imagine that we have defined the following class:
+\code
+class AvatarExample : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QPixmap avatar READ avatar WRITE setAvatar NOTIFY avatarChanged)
+public:
+ AvatarExample(QObject *parent = 0) : QObject(parent), m_value(100, 100) { m_value.fill(Qt::blue); }
+ ~AvatarExample() {}
+
+ QPixmap avatar() const { return m_value; }
+ void setAvatar(QPixmap v) { m_value = v; emit avatarChanged(); }
+
+signals:
+ void avatarChanged();
+
+private:
+ QPixmap m_value;
+};
+\endcode
+
+and that we have registered it with the QML type-system as follows:
+\code
+qmlRegisterType<AvatarExample>("Qt.example", 1, 0, "AvatarExample");
+\endcode
+
+The AvatarExample class has a property which is a pixmap. When the property
+is accessed in JavaScript scope, a copy of the resource will be created and
+stored in a JavaScript object which can then be used within JavaScript. This
+copy will take up valuable system resources, and so by default the scarce
+resource copy in the JavaScript object will be released automatically by the
+declarative engine once evaluation of the JavaScript expression is complete,
+unless the client explicitly preserves it.
+
+\section2 Example One: Automatic Release
+
+In this example, the resource will be automatically
+released after the binding expression evaluation is
+complete.
+
+\qml
+// exampleOne.qml
+import QtQuick 1.0
+import Qt.example 1.0
+
+QtObject {
+ property AvatarExample a;
+ a: AvatarExample { id: example }
+ property variant avatar: example.avatar
+}
+\endqml
+
+\code
+QDeclarativeComponent component(&engine, "exampleOne.qml");
+QObject *object = component.create();
+// The scarce resource will have been released automatically
+// after the binding expression was evaluated.
+// Since the scarce resource was not released explicitly prior
+// to the binding expression being evaluated, we get the
+// expected result:
+//object->property("scarceResourceCopy").isValid() == true
+delete object;
+\endcode
+
+\section2 Example Two: Explicit Preservation
+
+In this example, the resource must be explicitly preserved in order
+to prevent the declarative engine from automatically releasing the
+resource after evaluation of the imported script.
+
+\code
+// exampleTwo.js
+.import Qt.example 1.0 as QtExample
+
+var component = Qt.createComponent("exampleOne.qml");
+var exampleOneElement = component.createObject(null);
+var avatarExample = exampleOneElement.a;
+var retn = avatarExample.avatar;
+
+// without the following call, the scarce resource held
+// by retn would be automatically released by the engine
+// after the import statement in exampleTwo.qml, prior
+// to the variable assignment.
+retn.preserve();
+
+function importAvatar() {
+ return retn;
+}
+\endcode
+
+\qml
+// exampleTwo.qml
+import QtQuick 1.0
+import Qt.example 1.0
+import "exampleTwo.js" as ExampleTwoJs
+
+QtObject {
+ property variant avatar: ExampleTwoJs.importAvatar()
+}
+\endqml
+
+\code
+QDeclarativeComponent component(&engine, "exampleTwo.qml");
+QObject *object = component.create();
+// The resource was preserved explicitly during evaluation of the
+// JavaScript expression. Thus, during property assignment, the
+// scarce resource was still valid, and so we get the expected result:
+//object->property("avatar").isValid() == true
+// The scarce resource may not have been cleaned up by the JS GC yet;
+// it will continue to consume system resources until the JS GC runs.
+delete object;
+\endcode
+
+\section2 Example Three: Explicit Destruction
+
+In the following example, we release (via destroy()) an explicitly preserved
+scarce resource variant. This example shows how a client may free system
+resources by releasing the scarce resource held in a JavaScript object, if
+required, during evaluation of a JavaScript expression.
+
+\code
+// exampleThree.js
+.import Qt.example 1.0 as QtExample
+
+var component = Qt.createComponent("exampleOne.qml");
+var exampleOneElement = component.createObject(null);
+var avatarExample = exampleOneElement.a;
+var retn = avatarExample.avatar;
+retn.preserve();
+
+function importAvatar() {
+ return retn;
+}
+
+function releaseAvatar() {
+ retn.destroy();
+}
+\endcode
+
+\qml
+// exampleThree.qml
+import QtQuick 1.0
+import Qt.example 1.0
+import "exampleThree.js" as ExampleThreeJs
+
+QtObject {
+ property variant avatarOne
+ property variant avatarTwo
+
+ Component.onCompleted: {
+ avatarOne = ExampleThreeJs.importAvatar(); // valid at this stage
+ ExampleThreeJs.releaseAvatar(); // explicit release
+ avatarTwo = ExampleThreeJs.importAvatar(); // invalid at this stage
+ }
+}
+\endqml
+
+\code
+QDeclarativeComponent component(&engine, "exampleThree.qml");
+QObject *object = component.create();
+// The scarce resource was explicitly preserved by the client during
+// the evaluation of the imported script, and so the scarce resource
+// remains valid until the explicit call to releaseAvatar(). As such,
+// we get the expected results:
+//object->property("avatarOne").isValid() == true
+//object->property("avatarTwo").isValid() == false
+// Because the scarce resource was released explicitly, it will no longer
+// be consuming any system resources (beyond what a normal JS Object would;
+// that small overhead will exist until the JS GC runs, as per any other
+// JavaScript object).
+delete object;
+\endcode
+
*/
diff --git a/doc/src/declarative/modules.qdoc b/doc/src/declarative/modules.qdoc
index e0240c11ea..80d83a40d2 100644
--- a/doc/src/declarative/modules.qdoc
+++ b/doc/src/declarative/modules.qdoc
@@ -310,6 +310,7 @@ It is defined by a plain text file named "qmldir" that contains one or more line
<TypeName> [<InitialVersion>] <File>
internal <TypeName> <File>
plugin <Name> [<Path>]
+typeinfo <File>
\endcode
\bold {# <Comment>} lines are used for comments. They are ignored by the QML engine.
@@ -350,6 +351,14 @@ plugin file, or a relative path from the directory containing the \c qmldir file
containing the plugin file. By default the engine searches for the plugin library in the directory that contains the \c qmldir
file. The plugin search path can be queried with QDeclarativeEngine::pluginPathList() and modified using QDeclarativeEngine::addPluginPath(). When running the \l {QML Viewer}, use the \c -P option to add paths to the plugin search path.
+\bold {typeinfo <File>} lines add \l{Writing a qmltypes file}{type description files} to
+the module that can be read by QML tools such as Qt Creator to get information about the
+types defined by the module's plugins. <File> is the (relative) file name of a .qmltypes
+file.
+
+Without such a file QML tools may be unable to offer features such as code completion
+for the types defined in your plugins.
+
\section1 Debugging
@@ -358,5 +367,119 @@ when there are problems with finding and loading modules. See
\l{Debugging module imports} for more information.
+\section1 Writing a qmltypes file
+
+QML modules may refer to one or more type information files in their
+\l{Writing a qmldir file}{qmldir} file. These usually have the .qmltypes
+extension and are read by external tools to gain information about
+types defined in plugins.
+
+As such qmltypes files have no effect on the functionality of a QML module.
+Their only use is to allow tools such as Qt Creator to provide code completion,
+error checking and other functionality to users of your module.
+
+Any module that uses plugins should also ship a type description file.
+
+The best way to create a qmltypes file for your module is to generate it
+using the \c qmlplugindump tool that is provided with Qt.
+
+Example:
+If your module is in \c /tmp/imports/My/Module, you could run
+\code
+qmlplugindump My.Module 1.0 /tmp/imports > /tmp/imports/My/Module/mymodule.qmltypes
+\endcode
+to generate type information for your module. Afterwards, add the line
+\code
+typeinfo mymodule.qmltypes
+\endcode
+to \c /tmp/imports/My/Module/qmldir to register it.
+
+While the qmldump tool covers most cases, it does not work if:
+\list
+\o The plugin uses a \l{QDeclarativeCustomParser}. The component that uses
+ the custom parser will not get its members documented.
+\o The plugin can not be loaded. In particular if you cross-compiled
+ the plugin for a different architecture, qmldump will not be able to
+ load it.
+\endlist
+
+In case you have to create a qmltypes file manually or need to adjust
+an existing one, this is the file format:
+
+\qml
+import QtQuick.tooling 1.0
+
+// There always is a single Module object that contains all
+// Component objects.
+Module {
+ // A Component object directly corresponds to a type exported
+ // in a plugin with a call to qmlRegisterType.
+ Component {
+
+ // The name is a unique identifier used to refer to this type.
+ // It is recommended you simply use the C++ type name.
+ name: "QDeclarativeAbstractAnimation"
+
+ // The name of the prototype Component.
+ prototype: "QObject"
+
+ // The name of the default property.
+ defaultProperty: "animations"
+
+ // The name of the type containing attached properties
+ // and methods.
+ attachedType: "QDeclarativeAnimationAttached"
+
+ // The list of exports determines how a type can be imported.
+ // Each string has the format "URI/Name version" and matches the
+ // arguments to qmlRegisterType. Usually types are only exported
+ // once, if at all.
+ // If the "URI/" part of the string is missing that means the
+ // type should be put into the package defined by the URI the
+ // module was imported with.
+ // For example if this module was imported with 'import Foo 4.8'
+ // the Animation object would be found in the package Foo and
+ // QtQuick.
+ exports: [
+ "Animation 4.7",
+ "QtQuick/Animation 1.0"
+ ]
+
+ Property {
+ name: "animations";
+ type: "QDeclarativeAbstractAnimation"
+ // defaults to false, whether this property is read only
+ isReadonly: true
+ // defaults to false, whether the type of this property was a pointer in C++
+ isPointer: true
+ // defaults to false: whether the type actually is a QDeclarativeListProperty<type>
+ isList: true
+ }
+ Property { name: "loops"; type: "int" }
+ Property { name: "name"; type: "string" }
+ Property { name: "loopsEnum"; type: "Loops" }
+
+ Enum {
+ name: "Loops"
+ values: {
+ "Infinite": -2,
+ "OnceOnly": 1
+ }
+ }
+
+ // Signal and Method work the same way. The inner Parameter
+ // declarations also support the isReadonly, isPointer and isList
+ // attributes which mean the same as for Property
+ Method { name: "restart" }
+ Signal { name: "started" }
+ Signal {
+ name: "runningChanged"
+ Parameter { type: "bool" }
+ Parameter { name: "foo"; type: "bool" }
+ }
+ }
+}
+\endqml
+
*/
/
diff --git a/doc/src/declarative/qdeclarativeintro.qdoc b/doc/src/declarative/qdeclarativeintro.qdoc
index f4fd196830..96f73d0937 100644
--- a/doc/src/declarative/qdeclarativeintro.qdoc
+++ b/doc/src/declarative/qdeclarativeintro.qdoc
@@ -320,6 +320,14 @@ Text {
In the element documentation grouped properties are shown using the 'dot' notation.
+While you can bind the entire group at once, like below, note that setting any of the
+grouped properties will result in setting the group and thus invalidate the binding.
+\qml
+Text {
+ font: otherText.font
+}
+\endqml
+
\section2 Attached Properties
\target attached-properties
diff --git a/doc/src/declarative/qmltest.qdoc b/doc/src/declarative/qmltest.qdoc
new file mode 100644
index 0000000000..fdecf21183
--- /dev/null
+++ b/doc/src/declarative/qmltest.qdoc
@@ -0,0 +1,123 @@
+/****************************************************************************
+**
+** 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:FDL$
+** 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 Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of this
+** file.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \page qmltest.html
+ \title QtQuickTest Reference Documentation
+ \keyword QtQuickTest Reference Documentation
+
+ \section1 Introduction
+
+ QtQuickTest is a unit test framework for Qt Quick (QML) applications.
+ Test cases are written as JavaScript functions within a TestCase
+ element:
+
+ \code
+ import QtQuick 2.0
+ import QtTest 1.0
+
+ TestCase {
+ name: "MathTests"
+
+ function test_math() {
+ compare(2 + 2, 4, "2 + 2 = 4")
+ }
+
+ function test_fail() {
+ compare(2 + 2, 5, "2 + 2 = 5")
+ }
+ }
+ \endcode
+
+ Functions whose names start with \c{test_} are treated as test cases
+ to be executed. See the documentation for the \l TestCase and
+ \l SignalSpy elements for more information on writing test cases.
+
+ \section1 Running tests
+
+ Test cases are launched by a C++ harness that consists of
+ the following code:
+
+ \code
+ #include <QtQuickTest/quicktest.h>
+ QUICK_TEST_MAIN(example)
+ \endcode
+
+ Where "example" is an identifier to use to uniquely identify
+ this set of tests. You should add \c{CONFIG += qmltestcase}.
+ for example:
+
+ \code
+ TEMPLATE = app
+ TARGET = tst_example
+ CONFIG += warn_on qmltestcase
+ SOURCES += tst_example.cpp
+ \endcode
+
+ The test harness scans the specified source directory recursively
+ for "tst_*.qml" files. If \c{QUICK_TEST_SOURCE_DIR} is not defined,
+ then the current directory will be scanned when the harness is run.
+ Other *.qml files may appear for auxillary QML components that are
+ used by the test.
+
+ The \c{-input} command-line option can be set at runtime to run
+ test cases from a different directory. This may be needed to run
+ tests on a target device where the compiled-in directory name refers
+ to a host. For example:
+
+ \code
+ tst_example -input /mnt/SDCard/qmltests
+ \endcode
+
+ See \c{tests/qmlauto} in the source tree for an example of creating a
+ test harness that uses the \c{QUICK_TEST_SOURCE_DIR} macro.
+
+ If your test case needs QML imports, then you can add them as
+ \c{-import} options to the the test program command-line by adding
+ the following line to your .pro file:
+
+ \code
+ IMPORTPATH += $$PWD/../imports/my_module1 $$PWD/../imports/my_module2
+ \endcode
+
+ \section1 Running tests with QtQuick 1
+
+ The \c{-qtquick1} option can be passed to a test binary to run
+ the tests using QDeclarativeView (QtQuick 1) rather than QSGView (QtQuick 2):
+
+ \code
+ tst_example -qtquick1
+ \endcode
+
+ To run tests with either QtQuick 1 or QtQuick 2, use
+ "import QtQuick 1.0" in your unit tests and then specify
+ compatibility mode to the QtQuick2 engine:
+
+ \code
+ QMLSCENE_IMPORT_NAME=quick1 tst_example
+ \endcode
+*/
diff --git a/doc/src/declarative/whatsnew.qdoc b/doc/src/declarative/whatsnew.qdoc
index 9757201ee0..1c53c12446 100644
--- a/doc/src/declarative/whatsnew.qdoc
+++ b/doc/src/declarative/whatsnew.qdoc
@@ -29,6 +29,12 @@
\title What's New in Qt Quick
\page qtquick-whatsnew.html
+\section1 Qt 5.0.0 includes QtQuick 2.0
+
+QtQuick 2.0 is a major update.
+
+MouseArea now propagates clicked, doubleClicked and pressAndHold differently.
+
\section1 Qt 4.7.4 includes QtQuick 1.1
QtQuick 1.1 is a minor feature update. \e {import QtQuick 1.1} to use the new
diff --git a/doc/src/images/declarative-gridmesh.png b/doc/src/images/declarative-gridmesh.png
new file mode 100644
index 0000000000..6007d3b9e3
--- /dev/null
+++ b/doc/src/images/declarative-gridmesh.png
Binary files differ
diff --git a/doc/src/images/declarative-shadereffectitem.png b/doc/src/images/declarative-shadereffectitem.png
new file mode 100644
index 0000000000..2c8e8447e7
--- /dev/null
+++ b/doc/src/images/declarative-shadereffectitem.png
Binary files differ
diff --git a/doc/src/images/declarative-shadereffectsource.png b/doc/src/images/declarative-shadereffectsource.png
new file mode 100644
index 0000000000..86d6d1ea35
--- /dev/null
+++ b/doc/src/images/declarative-shadereffectsource.png
Binary files differ
diff --git a/doc/src/images/declarative-textballoons_example.png b/doc/src/images/declarative-textballoons_example.png
new file mode 100644
index 0000000000..d572de597c
--- /dev/null
+++ b/doc/src/images/declarative-textballoons_example.png
Binary files differ
diff --git a/doc/src/snippets/declarative/codingconventions/myscript.js b/doc/src/snippets/declarative/codingconventions/myscript.js
new file mode 100644
index 0000000000..cfa646250b
--- /dev/null
+++ b/doc/src/snippets/declarative/codingconventions/myscript.js
@@ -0,0 +1,9 @@
+function calculateWidth(parent)
+{
+ var w = parent.width / 3
+ // ...
+ // more javascript code
+ // ...
+ console.debug(w)
+ return w
+}
diff --git a/doc/src/snippets/declarative/focus/myclickablewidget.qml b/doc/src/snippets/declarative/focus/MyClickableWidget.qml
index 30b1c699c9..30b1c699c9 100644
--- a/doc/src/snippets/declarative/focus/myclickablewidget.qml
+++ b/doc/src/snippets/declarative/focus/MyClickableWidget.qml
diff --git a/doc/src/snippets/declarative/focus/mywidget.qml b/doc/src/snippets/declarative/focus/MyWidget.qml
index 0cca7479e8..0cca7479e8 100644
--- a/doc/src/snippets/declarative/focus/mywidget.qml
+++ b/doc/src/snippets/declarative/focus/MyWidget.qml
diff --git a/doc/src/snippets/declarative/models/views-models-delegates.qml b/doc/src/snippets/declarative/models/views-models-delegates.qml
index 2f76856ca6..e02cb1a11f 100644
--- a/doc/src/snippets/declarative/models/views-models-delegates.qml
+++ b/doc/src/snippets/declarative/models/views-models-delegates.qml
@@ -37,6 +37,7 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+import QtQuick 1.0
//! [rectangle]
Rectangle {
diff --git a/doc/src/snippets/declarative/models/visual-model-and-view.qml b/doc/src/snippets/declarative/models/visual-model-and-view.qml
index 4d42b6585c..824d57230f 100644
--- a/doc/src/snippets/declarative/models/visual-model-and-view.qml
+++ b/doc/src/snippets/declarative/models/visual-model-and-view.qml
@@ -37,6 +37,7 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+import QtQuick 1.0
Rectangle {
width: 200; height: 200
diff --git a/doc/src/snippets/declarative/webview/webview.qml b/doc/src/snippets/declarative/righttoleft/Child.qml
index f652369ca3..48cb295587 100644
--- a/doc/src/snippets/declarative/webview/webview.qml
+++ b/doc/src/snippets/declarative/righttoleft/Child.qml
@@ -38,16 +38,14 @@
**
****************************************************************************/
-//! [document]
-//! [import]
-import QtWebKit 1.0
-//! [import]
+import QtQuick 1.0
-WebView {
- url: "http://www.nokia.com"
- preferredWidth: 490
- preferredHeight: 400
- scale: 0.5
- smooth: false
+Rectangle {
+ width: 50; height: 50
+ color: "black"
+ Text {
+ color: "white"
+ text: String.fromCharCode(65 + Math.floor(26*Math.random()))
+ anchors.centerIn: parent
+ }
}
-//! [document]
diff --git a/doc/src/snippets/declarative/states/statechangescript.qml b/doc/src/snippets/declarative/states/statechangescript.qml
index aa1246d3fc..03d03f8a98 100644
--- a/doc/src/snippets/declarative/states/statechangescript.qml
+++ b/doc/src/snippets/declarative/states/statechangescript.qml
@@ -37,6 +37,7 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+
import QtQuick 1.0
Item {