summaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-07-29 03:13:56 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-07-29 03:13:56 (GMT)
commitd1e1f49ea0b742fd655112fdb30f5751e142a766 (patch)
tree627f51a48220ce488e2447bb63938c8fb30df94c /doc
parent24a4c2815d0dfed7ed925b22ab92b8b6aeb7924b (diff)
parent155f99502be75ff400bbae550328dbc79801d6c8 (diff)
downloadQt-d1e1f49ea0b742fd655112fdb30f5751e142a766.zip
Qt-d1e1f49ea0b742fd655112fdb30f5751e142a766.tar.gz
Qt-d1e1f49ea0b742fd655112fdb30f5751e142a766.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: Remove warnings in photoviewer demo. Uncomment code accidentally removed with 1937adaab5861ced44813c6a4b0bff1c3750ecd3 Fix image source Don't emit movementEnded if mouse press is a continuation of a flick. Avoid binding loop warnings Append 'Example' to titles of example pages Improvements to Modules docs Component docs Fixes for Dynamic Object Management docs. Also adds links to Update Symbian emulator QtOpenVGu.def, QtNetworku.def, QtCoreu.def files for Qt 4.7 to be in sync between respective def files in Qt 4.6.3
Diffstat (limited to 'doc')
-rw-r--r--doc/src/declarative/dynamicobjects.qdoc42
-rw-r--r--doc/src/declarative/extending-tutorial.qdoc6
-rw-r--r--doc/src/declarative/modules.qdoc293
-rw-r--r--doc/src/declarative/qtdeclarative.qdoc16
-rw-r--r--doc/src/examples/qml-examples.qdoc96
-rw-r--r--doc/src/snippets/declarative/component.qml60
-rw-r--r--doc/src/snippets/declarative/createComponent-simple.qml (renamed from doc/src/snippets/declarative/dynamicObjects.qml)32
-rw-r--r--doc/src/snippets/declarative/createQmlObject.qml4
-rw-r--r--doc/src/snippets/declarative/dynamicObjects-destroy.qml55
9 files changed, 438 insertions, 166 deletions
diff --git a/doc/src/declarative/dynamicobjects.qdoc b/doc/src/declarative/dynamicobjects.qdoc
index 300799c..997f601 100644
--- a/doc/src/declarative/dynamicobjects.qdoc
+++ b/doc/src/declarative/dynamicobjects.qdoc
@@ -148,17 +148,47 @@ lots of dynamically created items, however, you may receive a worthwhile
performance benefit if unused items are deleted.
Note that you should never manually delete items that were dynamically created
-by QML elements (such as \l Loader and \l Repeater). Also, you should generally avoid deleting
+by QML elements (such as \l Loader and \l Repeater). Also, you should avoid deleting
items that you did not dynamically create yourself.
Items can be deleted using the \c destroy() method. This method has an optional
argument (which defaults to 0) that specifies the approximate delay in milliseconds
-before the object is to be destroyed. This allows you to wait until the completion of
-an animation or transition. An example:
+before the object is to be destroyed.
-\snippet doc/src/snippets/declarative/dynamicObjects.qml 0
+Here is an example. The \c application.qml creates five instances of the \c SelfDestroyingRect.qml
+component. Each instance runs a NumberAnimation, and when the animation has finished, calls
+\c destroy() on its root item to destroy itself:
+
+\table
+\row
+\o \c application.qml
+\o \c SelfDestroyingRect.qml
+
+\row
+\o \snippet doc/src/snippets/declarative/dynamicObjects-destroy.qml 0
+\o \snippet doc/src/snippets/declarative/SelfDestroyingRect.qml 0
+
+\endtable
+
+Alternatively, the \c application.qml could have destroyed the created object
+by calling \c object.destroy().
+
+Notice that if a \c SelfDestroyingRect instance was created statically like this:
+
+\qml
+Item {
+ SelfDestroyingRect { ... }
+}
+\endqml
+
+This would result in an error, since items can only be dynamically
+destroyed if they were dynamically created.
+
+Objects created with \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()}
+can similarly be destroyed using \c destroy():
+
+\snippet doc/src/snippets/declarative/createQmlObject.qml 0
+\snippet doc/src/snippets/declarative/createQmlObject.qml destroy
-Here, \c Rectangle objects are destroyed one second after they are created, which is long
-enough for the \c NumberAnimation to be played before the object is destroyed.
*/
diff --git a/doc/src/declarative/extending-tutorial.qdoc b/doc/src/declarative/extending-tutorial.qdoc
index bc849b0..d128d0f 100644
--- a/doc/src/declarative/extending-tutorial.qdoc
+++ b/doc/src/declarative/extending-tutorial.qdoc
@@ -421,7 +421,7 @@ To create a plugin library, we need:
\list
\o A plugin class that registers our QML types
\o A project file that describes the plugin
-\o A "qmldir" file that tells the QML engine to load the plugin
+\o A \l{Writing a qmldir file}{qmldir} file that tells the QML engine to load the plugin
\endlist
First, we create a plugin class named \c ChartsPlugin. It subclasses QDeclarativeExtensionPlugin
@@ -441,8 +441,8 @@ and specifies with DESTDIR that library files should be built into a "lib" subdi
\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 "chapter6-plugin" (the name
+Finally, we add a \l{Writing a qmldir file}{qmldir} file that is automatically parsed by the QML engine.
+In this file, 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/chapter6-plugins/qmldir
diff --git a/doc/src/declarative/modules.qdoc b/doc/src/declarative/modules.qdoc
index 938222a..9e51a40 100644
--- a/doc/src/declarative/modules.qdoc
+++ b/doc/src/declarative/modules.qdoc
@@ -30,152 +30,277 @@
\title Modules
\section1 QML Modules
-A \bold {QML module} is a collection of QML types. They allow you to organize your QML content
-into independent units. Modules have an optional versioning mechanism that allows for independent
+
+A module is a set of QML content files that can be imported as a unit into a QML
+application. Modules can be used to organize QML content into independent units,
+and they can use a versioning mechanism that allows for independent
upgradability of the modules.
-There are two types of modules:
-location modules (defined by a URL),
-and
-installed modules (defined by a URI).
+While QML component files within the same directory are automatically accessible
+within the global namespace, components defined elsewhere must be imported
+explicitly using the \c import statement to import them as modules. For
+example, an \c import statement is required to use:
+
+\list
+\o A component defined in another QML file that is not in the same directory
+\o A component defined in a QML file located on a remote server
+\o A \l{QDeclarativeExtensionPlugin}{QML C++ plugin} library (unless the plugin is installed in the same directory)
+\o A JavaScript file (note this must be imported using \l {#namespaces}{named imports})
+\endlist
+
+An \c import statement includes the module name, and possibly a version number.
+This can be seen in the snippet commonly found at the top of QML files:
+
+\qml
+ import Qt 4.7
+\endqml
+
+This imports version 4.7 of the "Qt" module into the global namespace. (The QML
+library itself must be imported to use any of the \l {QML Elements}, as they
+are not included in the global namespace by default.)
+
+The \c Qt module is an \e installed module; it is found in the
+\l{The QML import path}{import path}. There are two types of QML modules:
+location modules (defined by a URL) and installed modules (defined by a URI).
+
+
+\section1 Location Modules
+
+Location modules can reside on the local filesystem or a network resource,
+and are referred to by a quoted location URL that specifies the filesystem
+or network URL. They allow any directory with QML content to be imported
+as a module, whether the directory is on the local filesystem or a remote
+server.
+
+For example, a QML project may have a separate directory for a set of
+custom UI components. These components can be accessed by importing the
+directory using a relative or absolute path, like this:
+
+\table
+\row
+\o Directory structure
+\o Contents of application.qml
+
+\row
+\o
+\code
+MyQMLProject
+ |- MyComponents
+ |- Slider.qml
+ |- CheckBox.qml
+ |- Main
+ |- application.qml
+\endcode
+
+\o
+\code
+import "../MyComponents"
+
+Slider { ... }
+CheckBox { ... }
+\endcode
+
+\endtable
-Location modules types are defined in QML files and \l{QDeclarativeExtensionPlugin}{QML C++ plugins}
-in a directory refered to directly by
-the location URL, either on the local filesystem, or as a network resource. The URL that locates them
-can be relative, in which case they actual URL is resolved by the QML file containing the import.
-When importing a location module, a quoted URL is used:
+Similarly, if the directory resided on a network source, it could
+be imported like this:
\code
-import "https://qml.nokia.com/qml/example" 1.0
-import "https://qml.nokia.com/qml/example" as NokiaExample
-import "mymodule" 1.0
-import "mymodule"
+ import "https://qml.nokia.com/qml/qmlcomponents"
+ import "https://qml.nokia.com/qml/qmlcomponents" 1.0
\endcode
-Installed modules can \e only be on the local file system or in application C++ code. Again they
-are defined in QML files and \l{QDeclarativeExtensionPlugin}{QML C++ plugins} in a directory,
-but the directory is indirectly referred to by the URI. The mapping to actual content is either
-by application C++ code registering a C++ type to a module URI (see \l{Extending QML in C++}),
-or in the referenced subdirectory of a path on the import path (see below).
-When importing a location module, an un-quoted URI is used:
+Remote location modules must have a \l{Writing a qmldir file}{qmldir file} in the
+same directory to specify which QML files should be made available. See the
+\l {#qmldirexample}{example} below. The qmldir file is optional for modules on
+the local filesystem.
+
+
+
+\section1 Installed modules
+
+
+Installed modules are modules that are installed on the
+local filesystem within the QML import path, or modules defined in C++
+application code. When importing an installed module, an un-quoted URI is
+used, with a mandatory version number:
\code
-import com.nokia.qml.mymodule 1.0
-import com.nokia.qml.mymodule as MyModule
+ import Qt 4.7
+ import com.nokia.qml.mymodule 1.0
\endcode
+Installed modules that are installed into the import path or created
+as a \l{QDeclarativeExtensionPlugin}{QML C++ plugin} must define a
+\l{Writing a qmldir file}{qmldir file}.
+
+
+\section2 The QML import path
-For either type of module, a \c qmldir file in the module directory defines the content of the module. This file is
-optional for location modules, but only for local filesystem content or a single remote content with a namespace.
-The second exception is explained in more detail in the section below on Namespaces.
+The QML engine will search the import path for a requested installed module.
+The default import path includes:
-\section2 The Import Path
+\list
+\o The directory of the current file
+\o The location specified by QLibraryInfo::ImportsPath
+\o Paths specified by the \c QML_IMPORT_PATH environment variable
+\endlist
-Installed modules are searched for on the import path.
-The \c -I option to the \l {QML Viewer} adds paths to the import path.
+The import path can be queried using QDeclarativeEngine::importPathList() and modified using QDeclarativeEngine::addImportPath().
-From C++, the path is available via \l QDeclarativeEngine::importPathList() and can be prepended to
-using \l QDeclarativeEngine::addImportPath().
+When running the \l {QML Viewer}, use the \c -I option to add paths to the import path.
-\section2 The \c qmldir File
-Installed QML modules and remote content without a namespace require a file \c qmldir which
-specifies the mapping from all type names to versioned QML files. It is a list of lines of the form:
+\section2 Creating installed modules in C++
+
+C++ applications can dynamically define installed modules using
+qmlRegisterType().
+
+For \l{QDeclarativeExtensionPlugin}{QML C++ plugins}, the
+module URI is automatically passed to QDeclarativeExtensionPlugin::registerTypes().
+The QDeclarativeExtensionPlugin documentation shows how to use this URI
+to call qmlRegisterType() to enable the plugin library to be built as
+an installed module. Once the plugin is built and installed, the module is importable
+in QML, like this:
+
+\code
+import com.nokia.TimeExample 1.0
+\endcode
+
+A \l{QDeclarativeExtensionPlugin}{QML C++ plugin} also requires a
+\l{Writing a qmldir file}{qmldir file} to make it available to the
+QML engine.
+
+
+
+\target namespaces
+\section1 Namespaces: Using Named Imports
+
+By default, when a module is imported, its contents are imported into the global namespace. You may choose to import the module into another namespace, either to allow identically-named types to be referenced, or purely for readability.
+
+To import a module into a specific namespace, use the \e as keyword:
+
+\qml
+ import Qt 4.7 as QtLibrary
+ import "../MyComponents" as MyComponents
+ import com.nokia.qml.mymodule 1.0 as MyModule
+\endqml
+
+Types from these modules can then only be used when qualified by the namespace:
+
+\qml
+ QtLibrary.Rectangle { ... }
+
+ MyComponents.Slider { ... }
+
+ MyModule.SomeComponent { ... }
+\endqml
+
+Multiple modules can be imported into the same namespace in the same way that multiple modules can be imported into the global namespace:
+
+\qml
+ import Qt 4.7 as Nokia
+ import Ovi 1.0 as Nokia
+\endqml
+
+\section2 JavaScript files
+
+JavaScript files must always be imported with a named import:
+
+\qml
+ import "somescript.js" as MyScript
+
+ Item {
+ //...
+ Component.onCompleted: MyScript.doSomething()
+ }
+\endqml
+
+
+
+\section1 Writing a qmldir file
+
+A \c qmldir file is a metadata file for a module that maps all type names in
+the module to versioned QML files. It is required for installed modules, and
+location modules that are loaded from a network source.
+
+It is defined by a plain text file named "qmldir" that contains one or more lines of the form:
\code
# <Comment>
<TypeName> [<InitialVersion>] <File>
-internal <Name> <File>
+internal <TypeName> <File>
plugin <Name> [<Path>]
\endcode
-# <Comment> lines are ignored, and can be used for comments.
+\bold {# <Commment>} lines are used for comments. They are ignored by the QML engine.
-<TypeName> <InitialVersion> <File> lines are used to add QML files as types.
-<TypeName> is the type being made available; the optional <InitialVersion> is a version
-number like \c 4.0; <File> is the (relative)
-file name of the QML file defining the type.
+\bold {<TypeName> [<InitialVersion>] <File>} lines are used to add QML files as types.
+<TypeName> is the type being made available, the optional <InitialVersion> is a version
+number, and <File> is the (relative) file name of the QML file defining the type.
Installed files do not need to import the module of which they are a part, as they can refer
to the other QML files in the module as relative (local) files, but
if the module is imported from a remote location, those files must nevertheless be listed in
the \c qmldir file. Types which you do not wish to export to users of your module
-may be marked with the \c internal keyword: \c internal <TypeName> <File>.
+may be marked with the \c internal keyword: \bold {internal <TypeName> <File>}.
The same type can be provided by different files in different versions, in which
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. 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.
+the import produces a runtime error, but if the user imports a version within the range of versions provided,
+even if no type is specific to that version, no error will occur.
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.
-
The versioning system ensures that a given QML file will work regardless of the version
of installed software, since a versioned import \e only imports types for that version,
leaving other identifiers available, even if the actual installed version might otherwise
provide those identifiers.
-\c plugin <Name> [<Path>] lines are used to add \l{QDeclarativeExtensionPlugin}{QML C++ plugins}
-to the module.
-
-<Name> is the name of the library. It is usually not the same as the file name
-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 {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().
+\bold {plugin <Name> [<Path>]} lines are used to add \l{QDeclarativeExtensionPlugin}{QML C++ plugins} to the module. <Name> is the name of the library. It is usually not the same as the file name
+of the plugin binary, which is platform dependent; e.g. the library \c MyAppTypes would produce
+\c libMyAppTypes.so on Linux and \c MyAppTypes.dll on Windows.
<Path> is an optional argument specifying either an absolute path to the directory containing the
plugin file, or a relative path from the directory containing the \c qmldir file to the directory
-containing the plugin 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.
-\section2 Namespaces - Named Imports
-When importing content it by default imports types into the global namespace.
-You may choose to import the module into another namespace, either to allow identically-named
-types to be referenced, or purely for readability.
+\target qmldirexample
+\section2 Example
-To import a module into a namespace:
+If the components in the \c MyComponents directory from the
+\l{Location Modules}{earlier example} were to be made available as a network resource,
+the directory would need to contain a \c qmldir file similar to this:
\code
-import Qt 4.7 as TheQtLibrary
+ComponentA 1.0 ComponentA.qml
+ComponentB 1.0 ComponentB.qml
\endcode
-Types from the Qt 4.7 module may then be used, but only by qualifying them with the namespace:
+The \c MyComponents directory could then be imported as a module using:
\code
-TheQtLibrary.Rectangle { ... }
-\endcode
-
-Multiple modules can be imported into the same namespace in the same way that multiple
-modules can be imported into the global namespace:
+import "http://the-server-name.com/MyComponents"
-\code
-import Qt 4.7 as Nokia
-import Ovi 1.0 as Nokia
+Slider { ... }
+CheckBox { ... }
\endcode
-While import statements are needed to make any types available in QML, the directory of the
-current file is implicitly loaded. This is the exact same as if you had added 'import "."' to
-the start of every QML file. The effect of this is that you can automatically use types defined in C++ plugins
-or QML files if they reside in the same directory. This is the last location searched for types - so if you
-happen to have a "Text.qml" file, or "text.qml" on case-insensitive file systems, it will not override
-the one from Qt if you import Qt.
-
-*/
+with an optional "1.0" version specification. Notice the import fails if
+a later version is used, as the \c qmldir file specifies that these elements
+are only available in the 1.0 version.
-/*
-Original requirement is QT-558.
+For examples of \c qmldir files for plugins, see the
+\l {declarative/cppextensions/plugins}{Plugins} example and
+\l {Tutorial: Writing QML extensions with C++}.
*/
+/
diff --git a/doc/src/declarative/qtdeclarative.qdoc b/doc/src/declarative/qtdeclarative.qdoc
index fb50286..413eb59 100644
--- a/doc/src/declarative/qtdeclarative.qdoc
+++ b/doc/src/declarative/qtdeclarative.qdoc
@@ -70,13 +70,23 @@
Returns the QML type id.
- Example: Register the C++ class \c MinehuntGame as the QML type
- named \c Game for version 0.1 in the import library \c MinehuntCore:
+ For example, this registers a C++ class \c MySliderItem as a QML type
+ named \c Slider for version 1.0 of a \l{QML Modules}{module} called
+ "com.mycompany.qmlcomponents":
\code
- qmlRegisterType<MinehuntGame>("MinehuntCore", 0, 1, "Game");
+ qmlRegisterType<MySliderItem>("com.mycompany.qmlcomponents", 1, 0, "Slider");
\endcode
+ Once this is registered, the type can be used in QML by importing the
+ specified module name and version number:
+
+ \qml
+ imoprt com.mycompany.qmlcomponents 1.0
+
+ Slider { ... }
+ \endqml
+
Note that it's perfectly reasonable for a library to register types to older versions
than the actual version of the library. Indeed, it is normal for the new library to allow
QML written to previous versions to continue to work, even if more advanced versions of
diff --git a/doc/src/examples/qml-examples.qdoc b/doc/src/examples/qml-examples.qdoc
index 3fd4ea8..a8be401 100644
--- a/doc/src/examples/qml-examples.qdoc
+++ b/doc/src/examples/qml-examples.qdoc
@@ -26,7 +26,7 @@
****************************************************************************/
/*!
- \title Animation: Basics
+ \title Animation: Basics Example
\example declarative/animation/basics
This example shows how to create and combine \l{QML Animation}{animations} in QML.
@@ -47,7 +47,7 @@
*/
/*!
- \title Animation: Behaviors
+ \title Animation: Behavior Examples
\example declarative/animation/behaviors
This example shows how to use QML behaviors.
@@ -56,7 +56,7 @@
*/
/*!
- \title Animation: Easing
+ \title Animation: Easing Example
\example declarative/animation/easing
This example shows the different easing modes available for \l{QML Animation}{animations}.
@@ -65,7 +65,7 @@
*/
/*!
- \title Animation: States
+ \title Animation: States Example
\example declarative/animation/states
These examples show how to use \l{States}{states} and \l{Transitions}{transitions}.
@@ -89,7 +89,7 @@
*/
/*!
- \title Image Elements: Border Image
+ \title Image Elements: Border Image Example
\example declarative/imageelements/borderimage
These examples show how to use the BorderImage element.
@@ -110,7 +110,7 @@
*/
/*!
- \title Image Elements: Image
+ \title Image Elements: Image Example
\example declarative/imageelements/image
This example shows how to use the \l Image element and its \l{Image::fillMode}{fillModes}.
@@ -147,7 +147,7 @@
*/
/*!
- \title C++ Extensions: Plugins
+ \title C++ Extensions: Plugins Example
\example declarative/cppextensions/plugins
This example shows how to create a C++ plugin extension by subclassing QDeclarativeExtensionPlugin.
@@ -156,7 +156,7 @@
*/
/*!
- \title LayoutItem
+ \title LayoutItem Example
\example declarative/cppextensions/qgraphicslayouts/layoutitem
This example show how to use the LayoutItem element to integrate QML items into an existing
@@ -165,7 +165,7 @@
\image qml-layoutitem-example.png
*/
/*!
- \title QGraphicsGridLayout
+ \title QGraphicsGridLayout Example
\example declarative/cppextensions/qgraphicslayouts/qgraphicsgridlayout
This example shows how to use QGraphicsGridLayout to lay out QML items. This is
@@ -175,7 +175,7 @@
\image qml-qgraphicsgridlayout-example.png
*/
/*!
- \title QGraphicsLinearLayout
+ \title QGraphicsLinearLayout Example
\example declarative/cppextensions/qgraphicslayouts/qgraphicslinearlayout
This example shows how to use QGraphicsLinearLayout to lay out QML items. This is
@@ -185,8 +185,8 @@
\image qml-qgraphicslinearlayout-example.png
*/
/*!
+ \title C++ Extensions: QGraphicsLayouts examples
\page declarative-cppextensions-qgraphicslayouts.html
- \title C++ Extensions: QGraphicsLayouts
These examples show how to integrate \l{Graphics View Framework}{Graphics View}
layout components with QML:
@@ -202,7 +202,7 @@
*/
/*!
- \title C++ Extensions: QWidgets
+ \title C++ Extensions: QWidgets Example
\example declarative/cppextensions/qwidgets
This example shows how to embed QWidget-based objects into QML using QGraphicsProxyWidget.
@@ -211,7 +211,7 @@
*/
/*!
- \title C++ Extensions: Image Provider
+ \title C++ Extensions: Image Provider Example
\example declarative/cppextensions/imageprovider
This examples shows how to use QDeclarativeImageProvider to serve images
@@ -221,7 +221,7 @@
*/
/*!
- \title C++ Extensions: Network access manager factory
+ \title C++ Extensions: Network Access Manager Factory Example
\example declarative/cppextensions/networkaccessmanagerfactory
This example shows how to use QDeclarativeNetworkAccessManagerFactory to create a QNetworkAccessManager
@@ -229,7 +229,7 @@
*/
/*!
- \title Internationlization
+ \title Internationlization Example
\example declarative/i18n
This example shows how to enable text translation in QML.
@@ -238,7 +238,7 @@
*/
/*!
- \title Positioners
+ \title Positioners Example
\example declarative/positioners
This example shows how to use positioner elements such as \l Row, \l Column,
@@ -248,7 +248,7 @@
*/
/*!
- \title Key Interaction: Focus
+ \title Key Interaction: Focus Example
\example declarative/keyinteraction/focus
This example shows how to handle keyboard input and focus in QML.
@@ -257,7 +257,7 @@
*/
/*!
- \title Models and Views: AbstractItemModel
+ \title Models and Views: AbstractItemModel Example
\example declarative/modelviews/abstractitemmodel
This example shows how to use a QAbstractItemModel subclass as a model in QML.
@@ -266,7 +266,7 @@
*/
/*!
- \title Models and Views: GridView
+ \title Models and Views: GridView Example
\example declarative/modelviews/gridview
This example shows how to use the GridView element.
@@ -275,7 +275,7 @@
*/
/*!
- \title Models and Views: ListView
+ \title Models and Views: ListView Example
\example declarative/modelviews/listview
These examples show how to use the ListView element.
@@ -317,7 +317,7 @@
*/
/*!
- \title Models and Views: PathView
+ \title Models and Views: PathView Example
\example declarative/modelviews/pathview
This example shows how to use the PathView element.
@@ -326,7 +326,7 @@
*/
/*!
- \title Models and Views: Object ListModel
+ \title Models and Views: Object ListModel Example
\example declarative/modelviews/objectlistmodel
This example shows how to use a QList<QObject*> as a model in QML.
@@ -335,7 +335,7 @@
*/
/*!
- \title Models and Views: Package
+ \title Models and Views: Package Example
\example declarative/modelviews/package
This example shows how to use the \l Package element.
@@ -344,7 +344,7 @@
*/
/*!
- \title Models and Views: Parallax
+ \title Models and Views: Parallax Example
\example declarative/modelviews/parallax
This example shows how to combine and switch between views.
@@ -353,7 +353,7 @@
*/
/*!
- \title Models and Views: String ListModel
+ \title Models and Views: String ListModel Example
\example declarative/modelviews/stringlistmodel
This example shows how to use a QStringList as a model in QML.
@@ -362,7 +362,7 @@
*/
/*!
- \title Models and Views: VisualItemModel
+ \title Models and Views: VisualItemModel Example
\example declarative/modelviews/visualitemmodel
This example shows how to use the VisualItemModel element.
@@ -371,7 +371,7 @@
*/
/*!
- \title Models and Views: WebView
+ \title Models and Views: WebView Example
\example declarative/modelviews/webview
These examples shows how to use the WebView element.
@@ -413,14 +413,14 @@
*/
/*!
- \title SQL Local Storage
+ \title SQL Local Storage Example
\example declarative/sqllocalstorage
This example shows how to use the SQL Local Storage API in QML.
*/
/*!
- \title Text: Fonts
+ \title Text: Fonts Example
\example declarative/text/fonts
These examples show how to discover available fonts from QML and manipulate
@@ -456,7 +456,7 @@
*/
/*!
- \title Text: Text Selection
+ \title Text: Text Selection Example
\example declarative/text/textselection
This example shows how text selection, copy and paste operations
@@ -466,7 +466,7 @@
*/
/*!
- \title Threading: Threaded ListModel
+ \title Threading: Threaded ListModel Example
\example declarative/threading/threadedlistmodel
This example shows how to use a ListModel from multiple threads using
@@ -474,14 +474,14 @@
*/
/*!
- \title Threading: WorkerScript
+ \title Threading: WorkerScript Example
\example declarative/threading/workerscript
This example shows how to use the WorkerScript element for threading in QML.
*/
/*!
- \title Toys: Clocks
+ \title Toys: Clocks Example
\example declarative/toys/clocks
This example displays a set of clocks with different times for different cities.
@@ -492,7 +492,7 @@
*/
/*!
- \title Toys: Corkboards
+ \title Toys: Corkboards Example
\example declarative/toys/corkboards
This example presents a flickable set of interactive corkboards. It is created
@@ -503,7 +503,7 @@
*/
/*!
- \title Toys: Dynamic Scene
+ \title Toys: Dynamic Scene Example
\example declarative/toys/dynamicscene
This example presents an interactive drag-and-drop scene. It demonstrates
@@ -514,7 +514,7 @@
*/
/*!
- \title Toys: Tic-Tac-Toe
+ \title Toys: Tic-Tac-Toe Example
\example declarative/toys/tic-tac-toe
This example presents a simple implementation of Tic Tac Toe.
@@ -523,7 +523,7 @@
*/
/*!
- \title Toys: TV Tennis
+ \title Toys: TV Tennis Example
\example declarative/toys/tvtennis
This example shows how to use animation components such as \l SpringAnimation,
@@ -533,14 +533,14 @@
*/
/*!
- \title Touch Interaction: Gestures
+ \title Touch Interaction: Gestures Example
\example declarative/touchinteraction/gestures
This example shows how to use the GestureArea element.
*/
/*!
- \title Touch Interaction: MouseArea
+ \title Touch Interaction: MouseArea Example
\example declarative/touchinteraction/mousearea
This example shows how to use the MouseArea element to access information
@@ -550,7 +550,7 @@
*/
/*!
- \title UI Components: Dial
+ \title UI Components: Dial Control Example
\example declarative/ui-components/dialcontrol
This example shows how to create a dial-type control. It combines
@@ -562,7 +562,7 @@
/*!
- \title UI Components: Flipable
+ \title UI Components: Flipable Example
\example declarative/ui-components/flipable
This example shows how to use the \l Flipable element.
@@ -571,7 +571,7 @@
*/
/*!
- \title UI Components: Progress Bars
+ \title UI Components: Progress Bars Example
\example declarative/ui-components/progressbar
This example shows how to create a progress bar.
@@ -580,7 +580,7 @@
*/
/*!
- \title UI Components: Scroll Bar
+ \title UI Components: Scroll Bar Example
\example declarative/ui-components/scrollbar
This example shows how to create scroll bars for a \l Flickable element
@@ -591,7 +591,7 @@
*/
/*!
- \title UI Components: Search Box
+ \title UI Components: Search Box Example
\example declarative/ui-components/searchbox
This example shows how to combine TextInput, FocusScope and BorderImage
@@ -601,7 +601,7 @@
*/
/*!
- \title UI Components: Slide Switch
+ \title UI Components: Slide Switch Example
\example declarative/ui-components/slideswitch
This example shows how to create a slide switch control.
@@ -610,7 +610,7 @@
*/
/*!
- \title UI Components: Spinner
+ \title UI Components: Spinner Example
\example declarative/ui-components/spinner
This example shows how to create a spinner-type component using the PathView element.
@@ -619,7 +619,7 @@
*/
/*!
- \title UI Components: Tab Widget
+ \title UI Components: Tab Widget Example
\example declarative/ui-components/tabwidget
This example shows how to create a tab widget. It also demonstrates how
@@ -630,7 +630,7 @@
*/
/*!
- \title XML: XMLHttpRequest
+ \title XML: XMLHttpRequest Example
\example declarative/xml/xmlhttprequest
This example shows how to use the \l XmlHttpRequest API in QML.
diff --git a/doc/src/snippets/declarative/component.qml b/doc/src/snippets/declarative/component.qml
new file mode 100644
index 0000000..09c4aa2
--- /dev/null
+++ b/doc/src/snippets/declarative/component.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** 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 QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+import Qt 4.7
+
+Item {
+ width: 100; height: 100
+
+ Component {
+ id: redSquare
+
+ Rectangle {
+ color: "red"
+ width: 10
+ height: 10
+ }
+ }
+
+ Loader { sourceComponent: redSquare }
+ Loader { sourceComponent: redSquare; x: 20 }
+}
+//![0]
diff --git a/doc/src/snippets/declarative/dynamicObjects.qml b/doc/src/snippets/declarative/createComponent-simple.qml
index 3698499..9669580 100644
--- a/doc/src/snippets/declarative/dynamicObjects.qml
+++ b/doc/src/snippets/declarative/createComponent-simple.qml
@@ -37,33 +37,21 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-
-import Qt 4.7
-
//![0]
-Rectangle {
- id: rootItem
- width: 300
- height: 300
-
- Component {
- id: rectComponent
-
- Rectangle {
- id: rect
- width: 40; height: 40;
- color: "red"
+import Qt 4.7
- NumberAnimation on opacity { from: 1; to: 0; duration: 1000 }
+Item {
+ id: container
+ width: 300; height: 300
- Component.onCompleted: rect.destroy(1000);
+ function loadButton() {
+ var component = Qt.createComponent("Button.qml");
+ if (component.status == Component.Ready) {
+ var button = component.createObject(container);
+ button.color = "red";
}
}
- function createRectangle() {
- var object = rectComponent.createObject(rootItem);
- }
-
- Component.onCompleted: createRectangle()
+ Component.onCompleted: loadButton()
}
//![0]
diff --git a/doc/src/snippets/declarative/createQmlObject.qml b/doc/src/snippets/declarative/createQmlObject.qml
index 64dd21d..a5f15f4 100644
--- a/doc/src/snippets/declarative/createQmlObject.qml
+++ b/doc/src/snippets/declarative/createQmlObject.qml
@@ -51,6 +51,10 @@ Rectangle {
var newObject = Qt.createQmlObject('import Qt 4.7; Rectangle {color: "red"; width: 20; height: 20}',
parentItem, "dynamicSnippet1");
//![0]
+
+//![destroy]
+newObject.destroy(1000);
+//![destroy]
}
Component.onCompleted: createIt()
diff --git a/doc/src/snippets/declarative/dynamicObjects-destroy.qml b/doc/src/snippets/declarative/dynamicObjects-destroy.qml
new file mode 100644
index 0000000..2c0c2fb
--- /dev/null
+++ b/doc/src/snippets/declarative/dynamicObjects-destroy.qml
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+import Qt 4.7
+
+Item {
+ id: container
+ width: 500; height: 100
+
+ Component.onCompleted: {
+ var component = Qt.createComponent("SelfDestroyingRect.qml");
+ for (var i=0; i<5; i++) {
+ var object = component.createObject(container);
+ object.x = (object.width + 10) * i;
+ }
+ }
+}
+//![0]