summaryrefslogtreecommitdiffstats
path: root/doc/src/declarative
diff options
context:
space:
mode:
Diffstat (limited to 'doc/src/declarative')
-rw-r--r--doc/src/declarative/elements.qdoc1
-rw-r--r--doc/src/declarative/globalobject.qdoc188
-rw-r--r--doc/src/declarative/measuring-performance.qdoc6
-rw-r--r--doc/src/declarative/qtdeclarative.qdoc7
-rw-r--r--doc/src/declarative/qtprogrammers.qdoc10
5 files changed, 177 insertions, 35 deletions
diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc
index 3ea5989..0eda95e 100644
--- a/doc/src/declarative/elements.qdoc
+++ b/doc/src/declarative/elements.qdoc
@@ -88,7 +88,6 @@ The following table lists the QML elements provided by the Qt Declarative module
\o \l ListModel, \l ListElement
\o \l VisualItemModel
\o \l XmlListModel and XmlRole
-\o \l SqlQuery, \l SqlConnection, and \l SqlBind
\o \l DateTimeFormatter
\o \l NumberFormatter
\endlist
diff --git a/doc/src/declarative/globalobject.qdoc b/doc/src/declarative/globalobject.qdoc
index afbe3db..e327047 100644
--- a/doc/src/declarative/globalobject.qdoc
+++ b/doc/src/declarative/globalobject.qdoc
@@ -42,7 +42,6 @@
/*!
\page qmlglobalobject.html
\title QML Global Object
-
Contains all the properties of the ECMAScript global object, plus:
\list
@@ -53,37 +52,186 @@ Contains all the properties of the ECMAScript global object, plus:
\o openDatabase
\endlist
+Contents:
+\tableofcontents
\section1 Qt Object
-The Qt object contains functions for
+The Qt object provides useful enums and functions from Qt, for use in all QML
+files.
-creating types:
-\list
-\o hsla
-\o rgba
-\o rect
-\o point
-\o size
-\o vector3d
-\endlist
+\section2 Enums
+The Qt object contains all enums in the Qt namespace. For example, you can
+access the AlignLeft member of the Qt::AlignmentFlag enum with \c Qt.AlignLeft.
+
+For a full list of enums, see the Qt Namespace documentation.
+
+\section2 Types
+The Qt object also contains helper functions for creating objects of specific
+data types. This is primarily useful when setting the properties of an item
+when the property has one of the following types:
-manipulating color:
\list
-\o lighter
-\o darker
-\o tint
+\o Color
+\o Rect
+\o Point
+\o Size
+\o Vector3D
\endlist
-and playing sound:
-\list
-\o playSound
+There are also string based constructors for these types, see \l{basicqmltypes.html}{Qml Types}.
+
+\section3 Qt.rgba(int red, int green, int blue, int alpha)
+This function returns a Color with the specified \c red, \c green, \c blue and \c alpha components. All components should be in the range 0-1 inclusive.
+
+\section3 Qt.hsla(int hue, int saturation, int lightness, int alpha)
+This function returns a Color with the specified \c hue, \c saturation, \c lightness and \c alpha components. All components should be in the range 0-1 inclusive.
+
+\section3 Qt.rect(int x, int y, int width, int height)
+This function returns a Rect with the top-left corner at \c x,\c y and the specified \c width and \c height.
+\section3 Qt.point(int x, int y)
+This function returns a Point with the specified \c x and \c y coordinates.
+\section3 Qt.size(int width, int height)
+returns as Size with the specified width and height.
+\section3 Qt.vector(real x, real y, real z)
+ This function is intended for use inside QML only. In C++ just create a
+ QVector3D as usual.
+
+ This function takes three numeric components and combines them into a
+ QVector3D value that can be used with any property that takes a
+ QVector3D argument. The following QML code:
+
+ \code
+ transform: Rotation {
+ id: rotation
+ origin.x: Container.width / 2;
+ axis: vector(0, 1, 1)
+ }
+ \endcode
+
+ is equivalent to:
+
+ \code
+ transform: Rotation {
+ id: rotation
+ origin.x: Container.width / 2;
+ axis.x: 0; axis.y: 1; axis.z: 0
+ }
+ \endcode
+
+
+\section2 Functions
+The Qt object also contains the following miscellaneous functions which expose Qt functionality for use in QML.
+
+\section3 Qt.lighter(color baseColor)
+This function returns a color 50% lighter than \c baseColor. See QColor::lighter() for further details.
+\section3 Qt.darker(color baseColor)
+This function returns a color 50% darker than \c baseColor. See QColor::lighter() for further details.
+\section3 Qt.tint(color baseColor, color tintColor)
+ This function allows tinting one color with another.
+
+ The tint color should usually be mostly transparent, or you will not be able to see the underlying color. The below example provides a slight red tint by having the tint color be pure red which is only 1/16th opaque.
+
+ \qml
+ Rectangle { x: 0; width: 80; height: 80; color: "lightsteelblue" }
+ Rectangle { x: 100; width: 80; height: 80; color: Qt.tint("lightsteelblue", "#10FF0000") }
+ \endqml
+ \image declarative-rect_tint.png
+
+ Tint is most useful when a subtle change is intended to be conveyed due to some event; you can then use tinting to more effectively tune the visible color.
+\section3 Qt.playSound(url soundLocation)
+This function plays the audio file located at \c soundLocation. Only .wav files are supported.
+
+\section3 Qt.openUrlExternally(url target)
+This function attempts to open the specified \c target url in an external application, based on the user's desktop preferences. It will return true if it succeeds, and false otherwise.
\endlist
-It also contains enum values used by some items.
+\section1 Dynamic Object Creation
+The following functions on the global object allow you to dynamically create QML
+items from files or strings.
-\section1 Asynchronous JavaScript and XML
+You can also dynamically create objects in a declarative manner, using items
+such as ListView, Repeater and Loader.
+
+\section2 createComponent(url file)
+ This function takes the URL of a QML file as its only argument. It returns
+ a component object which can be used to create and load that QML file.
+
+ Example QML script is below. Remember that QML files that might be loaded
+ over the network cannot be expected to be ready immediately.
+ \code
+ var component;
+ var sprite;
+ function finishCreation(){
+ if(component.isReady()){
+ sprite = component.createObject();
+ if(sprite == 0){
+ // Error Handling
+ }else{
+ sprite.parent = page;
+ sprite.x = 200;
+ //...
+ }
+ }else if(component.isError()){
+ // Error Handling
+ }
+ }
+
+ component = createComponent("Sprite.qml");
+ if(component.isReady()){
+ finishCreation();
+ }else{
+ component.statusChanged.connect(finishCreation);
+ }
+ \endcode
+
+ If you are certain the files will be local, you could simplify to
+ \code
+ component = createComponent("Sprite.qml");
+ sprite = component.createObject();
+ if(sprite == 0){
+ // Error Handling
+ print(component.errorsString());
+ }else{
+ sprite.parent = page;
+ sprite.x = 200;
+ //...
+ }
+ \endcode
+
+ If you want to just create an arbitrary string of QML, instead of
+ loading a QML file, consider the createQmlObject() function.
+
+\section2 createQmlObject(string qml, object parent, string filepath)
+ Creates a new object from the specified string of QML. It requires a
+ second argument, which is the id of an existing QML object to use as
+ the new object's parent. If a third argument is provided, this is used
+ for error reporting as the filepath that the QML came from.
+
+ Example (where targetItem is the id of an existing QML item):
+ \code
+ newObject = createQmlObject('import Qt 4.6; Rectangle {color: "red"; width: 20; height: 20}',
+ targetItem, "dynamicSnippet1");
+ \endcode
+
+ This function is intended for use inside QML only. It is intended to behave
+ similarly to eval, but for creating QML elements.
+
+ Returns the created object, or null if there is an error. In the case of an
+ error, details of the error are output using qWarning().
+
+ Note that this function returns immediately, and therefore may not work if
+ the QML loads new components. If you are trying to load a new component,
+ for example from a QML file, consider the createComponent() function
+ instead. 'New components' refers to external QML files that have not yet
+ been loaded, and so it is safe to use createQmlObject to load built-in
+ components.
+
+\section1 Asynchronous JavaScript and XML
+QML script supports the XMLHttpRequest object, which can be used to asynchronously obtain data from over a network.
+\section2 XMLHttpRequest()
+In QML you can construct an XMLHttpRequest object just like in a web browser! TODO: Real documentation for this object.
\section1 Offline Storage API
The \c openDatabase() and related functions
diff --git a/doc/src/declarative/measuring-performance.qdoc b/doc/src/declarative/measuring-performance.qdoc
index 01e7b03..bd1b0eb 100644
--- a/doc/src/declarative/measuring-performance.qdoc
+++ b/doc/src/declarative/measuring-performance.qdoc
@@ -71,14 +71,14 @@ Q_DEFINE_PERFORMANCE_METRIC(TextSize, "Text Size Calculation");
You could then use this category in the code:
\code
-void QFxText::updateSize()
+void QmlGraphicsText::updateSize()
{
- QFxPerfTimer<QFxPerf::TextSize> perf;
+ QmlPerfTimer<QmlPerf::TextSize> perf;
...
}
\endcode
-Because there is no cost for a QFxPerfTimer when Q_ENABLE_PERFORMANCE_LOG is not defined, this line can persist in the code and be used to help detect performance bottlenecks and regressions. See the QPerformanceLog documentation for more information on this performance framework.
+Because there is no cost for a QmlPerfTimer when Q_ENABLE_PERFORMANCE_LOG is not defined, this line can persist in the code and be used to help detect performance bottlenecks and regressions. See the QPerformanceLog documentation for more information on this performance framework.
\section1 FPS Measurements
diff --git a/doc/src/declarative/qtdeclarative.qdoc b/doc/src/declarative/qtdeclarative.qdoc
index 5d8623b..ea8e198 100644
--- a/doc/src/declarative/qtdeclarative.qdoc
+++ b/doc/src/declarative/qtdeclarative.qdoc
@@ -98,12 +98,7 @@ completely new applications. QML is fully \l {Extending QML}{extensible from C+
\section1 Reference:
\list
\o \l {QML Elements}
+\o \l {QML Global Object}
\o \l {Extending QML}
\endlist
-
-\section1 Deprecated
-\list
-\o \l {tutorials-declarative-contacts.html}{Tutorial: 'Introduction to QML'}
-\endlist
-
*/
diff --git a/doc/src/declarative/qtprogrammers.qdoc b/doc/src/declarative/qtprogrammers.qdoc
index 4c28255..6892005 100644
--- a/doc/src/declarative/qtprogrammers.qdoc
+++ b/doc/src/declarative/qtprogrammers.qdoc
@@ -84,14 +84,14 @@ QML Items also serve these purposes. Each is considered separately below.
\section2 Simple Widgets
-The most important rule to remember while implementing a new QFxItem in C++
+The most important rule to remember while implementing a new QmlGraphicsItem in C++
is that it should not contain any look and feel policies - leave that to the
QML usage of the item.
As an example, imagine you wanted a reusable Button item. If you therefore
-decided to write a QFxItem subclass to implement a button,
+decided to write a QmlGraphicsItem subclass to implement a button,
just as QToolButton subclasses QWidget for this purpose, following the rule above, your
-\c QFxButton would not have any appearance - just the notions of enabled, triggering, etc.
+\c QmlGraphicsButton would not have any appearance - just the notions of enabled, triggering, etc.
But there is already an object in Qt that does this: QAction.
@@ -103,8 +103,8 @@ The look and feel of an action - the appearance of the button, the transition be
and exactly how it respond to mouse, key, or touch input, should all be left for definition
in QML.
-It is illustrative to note that QFxTextEdit is built upon QTextControl,
-QFxWebView is built upon QWebPage, and ListView uses QListModelInterface,
+It is illustrative to note that QmlGraphicsTextEdit is built upon QTextControl,
+QmlGraphicsWebView is built upon QWebPage, and ListView uses QListModelInterface,
just as QTextEdit, QWebView, and QListView are built upon
those same UI-agnostic components.