aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/doc/src/syntax
diff options
context:
space:
mode:
authorJerome Pasion <jerome.pasion@digia.com>2013-04-17 17:19:35 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-23 12:53:48 +0200
commit32c54e57098b6799f41a3654a670a68619922f9e (patch)
tree86cf70e109e4a19628547d96e7fb13f6f2c46991 /src/qml/doc/src/syntax
parent28b6c39af1c3e919e83ddace18a5252c4423431b (diff)
Doc: Refactored and focused the Qt QML documentation.
Before it wasn't clear to what the module provided, especially with the coupling of Qt QML and Qt Quick. The doc is centered around these documentation: -QML refernce: the language syntax and the application constructs -JavaScript environment: the environment provided by the module -Integration with C++: more about the engine and the C++ API -QML Types and Classes reference (created by \qmlmodule and \module) The distinction are made in the directory and the section titles in the Qt QML landing page. Change-Id: I033bfcbf8368b94ffa5ee4b1225bee74347f53eb Reviewed-by: Martin Smith <martin.smith@digia.com>
Diffstat (limited to 'src/qml/doc/src/syntax')
-rw-r--r--src/qml/doc/src/syntax/basics.qdoc190
-rw-r--r--src/qml/doc/src/syntax/directoryimports.qdoc203
-rw-r--r--src/qml/doc/src/syntax/imports.qdoc308
-rw-r--r--src/qml/doc/src/syntax/objectattributes.qdoc983
-rw-r--r--src/qml/doc/src/syntax/propertybinding.qdoc189
-rw-r--r--src/qml/doc/src/syntax/signals.qdoc297
6 files changed, 0 insertions, 2170 deletions
diff --git a/src/qml/doc/src/syntax/basics.qdoc b/src/qml/doc/src/syntax/basics.qdoc
deleted file mode 100644
index d20f66d80a..0000000000
--- a/src/qml/doc/src/syntax/basics.qdoc
+++ /dev/null
@@ -1,190 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Free Documentation License Usage
-** 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. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: http://www.gnu.org/copyleft/fdl.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-/*!
-\page qtqml-syntax-basics.html
-\title QML Syntax Basics
-\brief Description of the basics of QML syntax
-
-QML is a declarative language that enables objects to be defined in terms of their attributes
-and how they relate and respond to changes in other objects. In contrast to imperative code, where changes in attributes and behavior are expressed through a series of statements that are processed step by step, the declarative QML syntax integrates attribute and behavioral changes directly into the definitions of individual objects.
-
-QML source code is generally loaded by the engine through QML \e documents, which are
-standalone documents of QML code. These can be used to define \l {QML Object Types}{QML object types} that can then be reused throughout an application.
-
-
-\section1 Import Statements
-
-A QML document may have one or more imports at the top of the file.
-An import can be any one of:
-
-\list
-\li a versioned namespace into which types have been registered (e.g., by a plugin)
-\li a relative directory which contains type-definitions as QML documents
-\li a JavaScript file
-\endlist
-
-JavaScript file imports must be qualified when imported, so that the properties and methods they provide can be accessed.
-
-The generic form of the various imports are as follows:
-\list
-\li \tt{import Namespace VersionMajor.VersionMinor}
-\li \tt{import Namespace VersionMajor.VersionMinor as SingletonTypeIdentifier}
-\li \tt{import "directory"}
-\li \tt{import "file.js" as ScriptIdentifier}
-\endlist
-
-Examples:
-\list
-\li \tt{import QtQuick 2.0}
-\li \tt{import QtQuick.LocalStorage 2.0 as Database}
-\li \tt{import "../privateComponents"}
-\li \tt{import "somefile.js" as Script}
-\endlist
-
-Please see the \l{qtqml-syntax-imports.html}{QML Syntax - Import Statements}
-documentation for in-depth information about QML imports.
-
-
-\keyword qml-object-declarations
-\section1 Object Declarations
-
-Syntactically, a block of QML code defines a tree of QML objects to be created. Objects are
-defined using \e {object declarations} that describe the type of object to be created as well
-as the attributes that are to be given to the object. Each object may also declare child objects
-using nested object declarations.
-
-An object declaration consists of the name of its object type, followed by a set of curly braces. All attributes and child objects are then declared within these braces.
-
-Here is a simple object declaration:
-
-\qml
-Rectangle {
- width: 100
- height: 100
- color: "red"
-}
-\endqml
-
-This declares an object of type \l Rectangle, followed by a set of curly braces that encompasses the attributes defined for that object. The \l Rectangle type is a type made available by the \l QtQuick module, and the attributes defined in this case are the values of the rectangle's \c width, \c height and \c color properties. (These are properties made available by the \l Rectangle type, as described in the \l Rectangle documentation.)
-
-The above object can be loaded by the engine if it is part of a \l{qtqml-documents-topic.html}{QML document}. That is, if the source code is complemented with \e import statement that imports the QtQuick module (to make the \l Rectangle type available), as below:
-
-\qml
-import QtQuick 2.0
-
-Rectangle {
- width: 100
- height: 100
- color: "red"
-}
-\endqml
-
-When placed into a \c .qml file and loaded by the QML engine, the above code creates a \l Rectangle object using the \l Rectangle type supplied by the QtQuick module:
-
-\image qtqml-syntax-basics-object-declaration.png
-
-\note If an object definition only has a small number of properties, it can be written on a single line like this, with the properties separated by semi-colons:
-
-\qml
-Rectangle { width: 100; height: 100; color: "red" }
-\endqml
-
-Obviously, the \l Rectangle object declared in this example is very simple indeed, as it defines nothing more than a few property values. To create more useful objects, an object declaration may define many other types of attributes: these are discussed in the \l{qtqml-syntax-objectattributes.html}{QML Object Attributes} documentation. Additionally, an object declaration may define child objects, as discussed below.
-
-
-\section2 Child Objects
-
-Any object declaration can define child objects through nested object declarations. In this way, \b {any object declaration implicitly declares an object tree that may contain any number of child objects}.
-
-For example, the \l Rectangle object declaration below includes a \l Gradient object declaration,
-which in turn contains two \l GradientStop declarations:
-
-\qml
-import QtQuick 2.0
-
-Rectangle {
- width: 100
- height: 100
-
- gradient: Gradient {
- GradientStop { position: 0.0; color: "yellow" }
- GradientStop { position: 1.0; color: "green" }
- }
-}
-\endqml
-
-When this code is loaded by the engine, it creates an object tree with a \l Rectangle object at the root; this object has a \l Gradient child object, which in turn has two \l GradientStop children.
-
-Note, however, that this is a parent-child relationship in the context of the QML object tree, not
-in the context of the visual scene. The concept of a parent-child relationship in a visual scene is provided by the \l Item type from the \l QtQuick module, which is the base type for most QML types, as most QML objects are intended to be visually rendered. For example, \l Rectangle and \l Text are both \l {Item}-based types, and below, a \l Text object has been declared as a visual child of a \l Rectangle object:
-
-\qml
-import QtQuick 2.0
-
-Rectangle {
- width: 200
- height: 200
- color: "red"
-
- Text {
- anchors.centerIn: parent
- text: "Hello, QML!"
- }
-}
-\endqml
-
-When the \l Text object refers to its \l {Item::parent}{parent} value in the above code, it is referring to its \e {visual parent}, not the parent in the object tree. In this case, they are one and the same: the \l Rectangle object is the parent of the \l Text object in both the context of the QML object tree as well as the context of the visual scene. However, while the \l {Item::parent}{parent} property can be modified to change the visual parent, the parent of an object in the context of the object tree cannot be changed from QML.
-
-(Additionally, notice that the \l Text object has been declared without assigning it to a property of the \l Rectangle, unlike the earlier example which assigned a \l Gradient object to the rectangle's \c gradient property. This is because the \l {Item::children}{children} property of \l Item has been set as the type's \l {qtqml-syntax-objectattributes.html#default-properties}{default property} to enable this more convenient syntax.)
-
-See the \l{qtquick-visualcanvas-visualparent.html}{visual parent} documentation for more information on the concept of visual parenting with the \l Item type.
-
-
-\section1 Comments
-
-The syntax for commenting in QML is similar to that of JavaScript:
-
-\list
-\li Single line comments start with // and finish at the end of the line.
-\li Multiline comments start with /* and finish with *\/
-\endlist
-
-\snippet qml/comments.qml 0
-
-Comments are ignored by the engine when processing QML code. They are useful for explaining what a section of code is doing, whether for reference at a later date or for explaining the implementation to others.
-
-Comments can also be used to prevent the execution of code, which is sometimes useful for tracking down problems.
-
-\qml
- Text {
- text: "Hello world!"
- //opacity: 0.5
- }
-\endqml
-
-In the above example, the \l Text object will have normal opacity, since the line opacity: 0.5 has been turned into a comment.
-*/
diff --git a/src/qml/doc/src/syntax/directoryimports.qdoc b/src/qml/doc/src/syntax/directoryimports.qdoc
deleted file mode 100644
index 7a6fb58c27..0000000000
--- a/src/qml/doc/src/syntax/directoryimports.qdoc
+++ /dev/null
@@ -1,203 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Free Documentation License Usage
-** 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. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: http://www.gnu.org/copyleft/fdl.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-/*!
-\page qtqml-syntax-directoryimports.html
-\title Importing QML Document Directories
-\brief Description of directory import statements in QML
-
-A local directory of QML files can be imported without any additional setup or
-configuration. A remote directory of QML files can also be imported, but
-requires a directory listing \c qmldir file to exist. A local directory may
-optionally contain a directory listing \c qmldir file in order to define the
-type names which should be provided to clients which import the directory, and
-to specify JavaScript resources which should be made available to importers.
-
-
-\section1 Local Directory Imports
-
-Any QML file on the local file system can import a local directory as using an
-import statement that refers to the directory's absolute or relative file
-system path, enabling the file to use the \l{qtqml-typesystem-objecttypes.html}
-{object types} defined within that directory.
-
-If the local directory contains a directory listing \c qmldir file, the types
-will be made available with the type names specified in the \c qmldir file;
-otherwise, they will be made available with type names derived from the
-filenames of the QML documents. Only filenames beginning with an uppercase
-letter and ending with ".qml" will be exposed as types if no \c qmldir file
-is specified in the directory.
-
-\section2 An Example
-
-Consider the following QML project directory structure. Under the top level directory \c myapp,
-there are a set of common UI components in a sub-directory named \c mycomponents, and the main
-application code in a sub-directory named \c main, like this:
-
-\code
-myapp
- |- mycomponents
- |- CheckBox.qml
- |- DialogBox.qml
- |- Slider.qml
- |- main
- |- application.qml
-\endcode
-
-The \c main/application.qml file can import the \c mycomponents directory using
-the relative path to that directory, allowing it to use the QML object types
-defined within that directory:
-
-\qml
-import "../mycomponents"
-
-DialogBox {
- CheckBox {
- // ...
- }
- Slider {
- // ...
- }
-}
-\endqml
-
-The directory may be imported into a qualified local namespace, in which case
-uses of any types provided in the directory must be qualified:
-
-\qml
-import "../mycomponents" as MyComponents
-
-MyComponents.DialogBox {
- // ...
-}
-\endqml
-
-The ability to import a local directory is convenient for cases such as
-in-application component sets and application prototyping, although any code
-that imports such modules must must update their relevant \c import statements
-if the module directory moves to another location. This can be avoided if
-\l{qtqml-modules-identifiedmodules.html}{QML modules} are used instead,
-as an installed module is imported with a unique identifier string rather than
-a file system path.
-
-
-\section1 Remotely Located Directories
-
-A directory of QML files can also be imported from a remote location if the
-directory contains a directory listing \c qmldir file.
-
-For example, if the \c myapp directory in the previous example was hosted at
-"http://www.my-example-server.com", and the \c mycomponents directory
-contained a \c qmldir file defined as follows:
-
-\code
-CheckBox CheckBox.qml
-DialogBox DialogBox.qml
-Slider Slider.qml
-\endcode
-
-Then, the directory could be imported using the URL to the remote
-\c mycomponents directory:
-
-\qml
-import "http://www.my-example-server.com/myapp/mycomponents"
-
-DialogBox {
- CheckBox {
- // ...
- }
- Slider {
- // ...
- }
-}
-\endqml
-
-Note that when a file imports a directory over a network, it can only access QML
-and JavaScript files specified in the \c qmldir file located in the directory.
-
-\warning When importing directories from a remote server, developers should
-always be careful to only load directories from trusted sources to avoid
-loading malicious code.
-
-
-\section1 Directory Listing qmldir Files
-
-A directory listing \c qmldir file distinctly different from a
-\l{qtqml-modules-qmldir.html}{module definition qmldir file}. A directory
-listing \c qmldir file allows a group of QML documents to be quickly and easily
-shared, but it does not define a type namespace into which the QML object types
-defined by the documents are registered, nor does it support versioning of
-those QML object types.
-
-The syntax of a directory listing \c qmldir file is as follows:
-\table
- \header
- \li Command
- \li Syntax
- \li Description
-
- \row
- \li Object Type Declaration
- \li <TypeName> <FileName>
- \li An object type declaration allows a QML document to be exposed with
- the given \c <TypeName>.
-
- Example:
- \code
-RoundedButton RoundedBtn.qml
- \endcode
-
- \row
- \li Internal Object Type Declaration
- \li internal <TypeName> <FileName>
- \li An internal object type declaration allows a QML document to be
- registered as a type which becomes available only to the other
- QML documents contained in the directory import. The internal
- type will not be made available to clients who import the directory.
-
- Example:
- \code
-internal HighlightedButton HighlightedBtn.qml
- \endcode
-
- \li JavaScript Resource Declaration
- \li <Identifier> <FileName>
- \li A JavaScript resource declaration allows a JavaScript file to be
- exposed via the given identifier.
-
- Example:
- \code
-MathFunctions mathfuncs.js
- \endcode
-\endtable
-
-A local file system directory may optionally include a \c qmldir file. This
-allows the engine to only expose certain QML types to clients who import the
-directory. Additionally, JavaScript resources in the directory are not exposed
-to clients unless they are declared in a \c qmldir file.
-
-*/
-
diff --git a/src/qml/doc/src/syntax/imports.qdoc b/src/qml/doc/src/syntax/imports.qdoc
deleted file mode 100644
index eda7dbf006..0000000000
--- a/src/qml/doc/src/syntax/imports.qdoc
+++ /dev/null
@@ -1,308 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Free Documentation License Usage
-** 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. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: http://www.gnu.org/copyleft/fdl.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-/*!
-\page qtqml-syntax-imports.html
-\title Import Statements
-\brief Description of import statements in QML
-
-\section1 Syntax of an Import Statement
-
-An import statement allows clients to tell the engine which modules, JavaScript
-resources and component directories are used within a QML document. The types
-which may be used within a document depends on which modules, resources and
-directories are imported by the document.
-
-\section2 Import Types
-
-There are three different types of imports. Each import type has a slightly
-different syntax, and different semantics apply to different import types.
-
-\section3 Module (Namespace) Imports
-
-The most common type of import is a module import. Clients can import
-\l{qtqml-modules-identifiedmodules.html}{QML modules} which register QML object
-types and JavaScript resources into a given namespace.
-
-The generic form of a module import is as follows:
-\code
-import <ModuleIdentifier> <Version.Number> [as <Qualifier>]
-\endcode
-
-\list
- \li The \c <ModuleIdentifier> is an identifier specified in dotted URI
- notation, which uniquely identifies the type namespace provided by the
- module.
- \li The \c <Version.Number> is a version of the form
- \c {MajorVersion.MinorVersion} which specifies which definitions of
- various object types and JavaScript resources will be made available due
- to the import.
- \li The \c <Qualifier> is an optional local namespace identifier into which
- the object types and JavaScript resources provided by the module will be
- installed, if given. If omitted, the object types and JavaScript
- resources provided by the module will be installed into the global
- namespace.
-\endlist
-
-An example of an unqualified module import is as follows:
-\code
-import QtQuick 2.0
-\endcode
-
-This import allows the use of all of the types provided by the \c QtQuick
-module without needing to specify a qualifier. For example, the client code to
-create a rectangle is as follows:
-
-\qml
-import QtQuick 2.0
-
-Rectangle {
- width: 200
- height: 100
- color: "red"
-}
-\endqml
-
-An example of a qualified module import is as follows:
-\code
-import QtQuick 2.0 as Quick
-\endcode
-
-This import allows multiple modules which provide conflicting type names to be
-imported at the same time, however since each usage of a type provided by a
-module which was imported into a qualified namespace must be preceded by the
-qualifier, the conflict is able to be resolved unambiguously by the QML engine.
-
-An example of client code which creates a rectangle after using a qualified
-module import is as follows:
-
-\qml
-import QtQuick 2.0 as Quick
-
-Quick.Rectangle {
- width: 200
- height: 100
- color: "red"
-}
-\endqml
-
-For more information about qualified imports, see the upcoming section on
-\l{Importing Into A Qualified Local Namespace}.
-
-Note that if a QML document does not import a module which provides a
-particular QML object type, but attempts to use that object type anyway,
-an error will occur. For example, the following QML document does not
-import \c QtQuick and thus attempting to use the \c Rectangle type will fail:
-
-\qml
-Rectangle {
- width: 200
- height: 100
- color: "red"
-}
-\endqml
-
-In this case, the engine will emit an error and refuse to load the file.
-
-\section4 Non-module Namespace Imports
-
-Types can also be registered into namespaces directly via the various
-registration functions in C++ (such as qmlRegisterType()). The types which
-have been registered into a namespace in this way may be imported by importing
-the namespace, as if the namespace was a module identifier.
-
-This is most common in client applications which define their own QML object
-types in C++ and register them with the QML type system manually.
-
-\section4 Importing into a Qualified Local Namespace
-
-The \c import statement may optionally use the \c as keyword to specify that
-the types should be imported into a particular document-local namespace. If a
-namespace is specified, then any references to the types made available by the
-import must be prefixed by the local namespace qualifier.
-
-Below, the QtQuick module is imported into the namespace "CoreItems". Now, any
-references to types from the \c QtQuick module must be prefixed with the
-\c CoreItems name:
-
-\qml
-import QtQuick 2.0 as CoreItems
-
-CoreItems.Rectangle {
- width: 100; height: 100
-
- CoreItems.Text { text: "Hello, world!" }
-
- // WRONG! No namespace prefix - the Text type won't be found
- Text { text: "Hello, world!" }
-}
-\endqml
-
-A namespace acts as an identifier for a module within the scope of the file.
-The namespace does not become an attribute of the root object that can be
-referred to externally as can be done with properties, signals and methods.
-
-The namespaced import is useful if there is a requirement to use two QML types
-that have the same name but are located in different modules. In this case the
-two modules can be imported into different namespaces to ensure the code is
-referring to the correct type:
-
-\qml
-import QtQuick 2.0 as CoreItems
-import "../textwidgets" as MyModule
-
-CoreItems.Rectangle {
- width: 100; height: 100
-
- MyModule.Text { text: "Hello from my custom text item!" }
- CoreItems.Text { text: "Hello from QtQuick!" }
-}
-\endqml
-
-Note that multiple modules can be imported into the same namespace in the same
-way that multiple modules can be imported into the global namespace. For example:
-
-\snippet qml/imports/merged-named-imports.qml imports
-
-\section3 Directory Imports
-
-A directory which contains QML documents may also be imported directly in a
-QML document. This provides a simple way for QML types to be segmented into
-reusable groupings: directories on the filesystem.
-
-The generic form of a directory import is as follows:
-\qml
-import "<DirectoryPath>" [as <Qualifier>]
-\endqml
-
-\note Import paths are network transparent: applications can import documents
-from remote paths just as simply as documents from local paths. See the general
-URL resolution rules for \l{qtqml-documents-networktransparency.html}
-{Network Transparency} in QML documents. If the directory is remote, it must
-contain a \l{qtqml-syntax-directoryimports.html#directory-listing-qmldir-files}
-{directory import listing qmldir file} as the QML engine cannot determine
-the contents of a remote directory if that \c qmldir file does not exist.
-
-Similar semantics for the \c <Qualifier> apply to directory imports as for
-module imports; for more information on the topic, please see the previous
-section about \l{Importing into a Qualified Local Namespace}.
-
-For more information about directory imports, please see the in-depth
-documentation about \l{qtqml-syntax-directoryimports.html}{directory imports}.
-
-\section3 JavaScript Resource Imports
-
-JavaScript resources may be imported directly in a QML document. Every
-JavaScript resource must have an identifier by which it is accessed.
-
-The generic form of a JavaScript resource import is as follows:
-\code
-import "<JavaScriptFile>" as <Identifier>
-\endcode
-
-Note that the \c <Identifier> must be unique within a QML document, unlike the
-local namespace qualifier which can be applied to module imports.
-
-\section4 JavaScript Resources from Modules
-
-Javascript files can be provided by modules, by adding identifier
-definitions to the \c qmldir file which specifies the module.
-
-For example, if the \c projects.MyQMLProject.MyFunctions module is specified
-with the following \c qmldir file, and installed into the QML import path:
-\code
-module projects.MyQMLProject.MyFunctions
-SystemFunctions 1.0 SystemFunctions.js
-UserFunctions 1.0 UserFunctions.js
-\endcode
-
-a client application is able to import the JavaScript resources declared in the
-module by importing the module and using the identifier associated with a
-declared resource:
-
-\qml
-import QtQuick 2.0
-import projects.MyQMLProject.MyFunctions 1.0
-
-Item {
- Component.onCompleted: { SystemFunctions.cleanUp(); }
-}
-\endqml
-
-If the module was imported into a document-local namespace, the JavaScript
-resource identifiers must be prefixed with the namespace qualifier in order
-to be used:
-
-\qml
-import QtQuick 2.0
-import projects.MyQMLProject.MyFunctions 1.0 as MyFuncs
-import org.example.Functions 1.0 as TheirFuncs
-
-Item {
- Component.onCompleted: {
- MyFuncs.SystemFunctions.cleanUp();
- TheirFuncs.SystemFunctions.shutdown();
- }
-}
-\endqml
-
-\section4 Further Information
-
-For more information about JavaScript resources, please see the documentation
-about \l{qtqml-javascript-resources.html}
-{defining JavaScript resources in QML}, and for more information about how
-to import JavaScript resources, and how imports can be used from within
-JavaScript resources, please see the in-depth documentation about
-\l{qtqml-javascript-imports.html}{importing JavaScript resources in QML}.
-
-
-\section1 QML Import Path
-
-When an \l{qtqml-modules-installedmodules.html}{installed module} is imported,
-the QML engine searches the \e{import path} for a matching module.
-
-This import path, as returned by QQmlEngine::importPathList(), defines the
-default locations to be searched by the engine. By default, this list contains:
-
-\list
-\li The directory of the current file
-\li The location specified by QLibraryInfo::Qml2ImportsPath
-\li Paths specified by the \c QML2_IMPORT_PATH environment variable
-\endlist
-
-Additional import paths can be added through QQmlEngine::addImportPath() or the
-\c QML2_IMPORT_PATH environment variable. When running the
-\l{Prototyping with qmlscene}{qmlscene} tool, you can also use the \c -I option
-to add an import path.
-
-
-\section1 Debugging
-
-The \c QML_IMPORT_TRACE environment variable can be useful for debugging
-when there are problems with finding and loading modules. See
-\l{Debugging module imports} for more information.
-
-*/
diff --git a/src/qml/doc/src/syntax/objectattributes.qdoc b/src/qml/doc/src/syntax/objectattributes.qdoc
deleted file mode 100644
index f336d14b14..0000000000
--- a/src/qml/doc/src/syntax/objectattributes.qdoc
+++ /dev/null
@@ -1,983 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Free Documentation License Usage
-** 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. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: http://www.gnu.org/copyleft/fdl.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
-\page qtqml-syntax-objectattributes.html
-\title QML Object Attributes
-\brief Description of QML object type attributes
-
-Every QML object type has a defined set of attributes. Each instance of an
-object type is created with the set of attributes that have been defined for
-that object type. There are several different kinds of attributes which
-can be specified, which are described below.
-
-\section1 Attributes in Object Declarations
-
-An \l{qtqml-syntax-basics.html#object-declarations}{object declaration} in a
-QML document defines a new type. It also declares an object hierarchy that
-will be instantiated should an instance of that newly defined type be created.
-
-The set of QML object-type attribute types is as follows:
-
-\list
-\li the \e id attribute
-\li property attributes
-\li signal attributes
-\li signal handler attributes
-\li method attributes
-\li attached properties and attached signal handler attributes
-\endlist
-
-These attributes are discussed in detail below.
-
-\section2 The \e id Attribute
-
-Every QML object type has exactly one \e id attribute. This attribute is
-provided by the language itself, and cannot be redefined or overridden by any
-QML object type.
-
-A value may be assigned to the \e id attribute of an object instance to allow
-that object to be identified and referred to by other objects. This \c id must
-begin with a lower-case letter or an underscore, and cannot contain characters
-other than letters, numbers and underscores.
-
-Below is a \l TextInput object and a \l Text object. The \l TextInput object's
-\c id value is set to "myTextInput". The \l Text object sets its \c text
-property to have the same value as the \c text property of the \l TextInput,
-by referring to \c myTextInput.text. Now, both items will display the same
-text:
-
-\qml
-import QtQuick 2.0
-
-Column {
- width: 200; height: 200
-
- TextInput { id: myTextInput; text: "Hello World" }
-
- Text { text: myTextInput.text }
-}
-\endqml
-
-An object can be referred to by its \c id from anywhere within the
-\e {component scope} in which it is declared. Therefore, an \c id value must
-always be unique within its component scope. See
-\l{qtqml-documents-scope.html}{Scope and Naming Resolution} for more
-information.
-
-Once an object instance is created, the value of its \e id attribute cannot
-be changed. While it may look like an ordinary property, the \c id attribute
-is \b{not} an ordinary \c property attribute, and special semantics apply
-to it; for example, it is not possible to access \c myTextInput.id in the above
-example.
-
-
-\section2 Property Attributes
-
-A property is an attribute of an object that can be assigned a static value
-or bound to a dynamic expression. A property's value can be read by other
-objects. Generally it can also be modified by another object, unless a
-particular QML type has explicitly disallowed this for a specific property.
-
-\section3 Defining Property Attributes
-
-A property may be defined for a type in C++ by registering a
-Q_PROPERTY of a class which is then registered with the QML type system.
-Alternatively, a custom property of an object type may be defined in
-an object declaration in a QML document with the following syntax:
-
-\code
- [default] property <propertyType> <propertyName>
-\endcode
-
-In this way an object declaration may \l {Defining Object Types from QML}
-{expose a particular value} to outside objects or maintain some internal
-state more easily.
-
-Property names must begin with a lower case letter and can only contain
-letters, numbers and underscores. \l {JavaScript Reserved Words}
-{JavaScript reserved words} are not valid property names. The \c default
-keyword is optional, and modifies the semantics of the property being declared.
-See the upcoming section on \l {Default Properties}{default properties} for
-more information about the \c default property modifier.
-
-Declaring a custom property implicitly creates a value-change
-\l{Signal attributes}{signal} for that property, as well as an associated
-\l{Signal handler attributes}{signal handler} called
-\e on<PropertyName>Changed, where \e <PropertyName> is the name of the
-property, with the first letter capitalized.
-
-For example, the following object declaration defines a new type which
-derives from the Rectangle base type. It has two new properties,
-with a \l{Signal handler attributes}{signal handler} implemented for one of
-those new properties:
-
-\qml
-Rectangle {
- property color previousColor
- property color nextColor
- onNextColorChanged: console.log("The next color will be: " + nextColor.toString())
-}
-\endqml
-
-\section4 Valid Types in Custom Property Definitions
-
-Any of the \l {QML Basic Types} aside from the \l enumeration type can be used
-as custom property types. For example, these are all valid property declarations:
-
-\qml
-Item {
- property int someNumber
- property string someString
- property url someUrl
-}
-\endqml
-
-(Enumeration values are simply whole number values and can be referred to with
-the \l int type instead.)
-
-Some basic types are provided by the \c QtQuick module and thus cannot be used
-as property types unless the module is imported. See the \l {QML Basic Types}
-documentation for more details.
-
-Note the \l var basic type is a generic placeholder type that can hold any
-type of value, including lists and objects:
-
-\code
-property var someNumber: 1.5
-property var someString: "abc"
-property var someBool: true
-property var someList: [1, 2, "three", "four"]
-property var someObject: Rectangle { width: 100; height: 100; color: "red" }
-\endcode
-
-Additionally, any \l{QML Object Types}{QML object type} can be used as a
-property type. For example:
-
-\code
-property Item someItem
-property Rectangle someRectangle
-\endcode
-
-This applies to \l {Defining Object Types from QML}{custom QML types} as well.
-If a QML type was defined in a file named \c ColorfulButton.qml (in a directory
-which was then imported by the client), then a property of type
-\c ColorfulButton would also be valid.
-
-
-\section3 Values of Property Attributes
-
-The value of a property of an object instance may specified in an
-object declaration in two separate ways:
-\list
- \li a value assignment on initialization
- \li an imperative value assignment
-\endlist
-
-The value in either case may be either a binding expression or a static value.
-
-\section4 Value Assignment on Initialization
-
-The syntax for assigning a value to a property on initialization is:
-
-\code
- <propertyName> : <value>
-\endcode
-
-An initialization value assignment may be combined with a property definition
-in an object declaration, if desired. In that case, the syntax of the property
-definition becomes:
-
-\code
- [default] property <propertyType> <propertyName> : <value>
-\endcode
-
-An example of property value initialization follows:
-
-\qml
-import QtQuick 2.0
-
-Rectangle {
- color: "red"
- property color nextColor: "blue" // combined property declaration and initialization
-}
-\endqml
-
-\section4 Imperative Value Assignment
-
-An imperative value assignment is where a property value (either static value
-or binding expression) is assigned to a property from imperative JavaScript
-code. The syntax of an imperative value assignment is just the JavaScript
-assignment operator, as shown below:
-
-\code
- [<objectId>.]<propertyName> = value
-\endcode
-
-An example of imperative value assignment follows:
-
-\qml
-import QtQuick 2.0
-
-Rectangle {
- id: rect
- Component.onCompleted: {
- rect.color = "red"
- }
-}
-\endqml
-
-\section4 Valid Property Values
-
-As previously noted, there are two kinds of values which may be assigned to a
-property: static values, and binding expression values.
-
-\table
- \header
- \li Kind
- \li Semantics
-
- \row
- \li Static Value
- \li A value whose type matches (or can be converted to) that of
- the property may be assigned to the property.
-
- \row
- \li Binding Expression
- \li A JavaScript expression which may be evaluated, whose result is a
- value whose type matches (or can be converted to) that of the
- property may be assigned to the property. The expression will be
- automatically re-evaluated (and the new result assigned to the
- property) by the QML engine should the value of any properties accessed
- during evaluation change.
-\endtable
-
-An example of these two types of values being assigned to properties follows:
-
-\qml
-import QtQuick 2.0
-
-Rectangle {
- // both of these are static value assignments on initialization
- width: 400
- height: 200
-
- Rectangle {
- // both of these are binding expression value assignments on initialization
- width: parent.width / 2
- height: parent.height
- }
-}
-\endqml
-
-In many cases, a string value may be converted automatically to a
-different type of value, as QML provides string converters for many property
-types (thus you can assign the string \c "red" to a color property).
-
-It is important to note that in order to assign a binding expression to a
-property in an imperative value assignment, the right-hand-side of
-the assignment (the binding expression) must be a function returned by the
-\l{Qt::binding()}{Qt.binding()} function, which returns a value of the
-appropriate type. A binding expression value may be assigned to a property
-via an initialization value assignment without using that function (and, in
-fact, attempting to do so will result in an error). See the documentation
-about \l{qtqml-syntax-propertybinding.html}{property binding} for more
-information on the topic.
-
-
-\section3 Type Safety
-
-Properties are type safe. A property can only be assigned a value that matches
-the property type.
-
-For example, if a property is a real, and if you try to assign a string to it,
-you will get an error:
-
-\code
-property int volume: "four" // generates an error; the property's object will not be loaded
-\endcode
-
-Likewise if a property is assigned a value of the wrong type during run time,
-the new value will not be assigned, and an error will be generated.
-
-As noted in a previous section, some property types do not have a natural
-value representation, and for those property types the QML engine
-automatically performs string-to-typed-value conversion. So, for example,
-even though properties of the \c color type store colors and not strings,
-you are able to assign the string \c "red" to a color property, without an
-error being reported.
-
-See \l {QML Basic Types} for a list of the types of properties that are
-supported by default. Additionally, any available \l {QML Object Types}
-{QML object type} may also be used as a property type.
-
-\section3 Special Property Types
-
-\section4 Object List Property Attributes
-
-A \l list type property can be assigned a list of QML object-type values.
-The syntax for defining an object list value is a comma-separated list
-surrounded by square brackets:
-
-\code
- [ <item 1>, <item 2>, ... ]
-\endcode
-
-For example, the \l Item type has a \l {Item::states}{states} property that is
-used to hold a list of \l State type objects. The code below initializes the
-value of this property to a list of three \l State objects:
-
-\qml
-import QtQuick 2.0
-
-Item {
- states: [
- State { name: "loading" },
- State { name: "running" },
- State { name: "stopped" }
- ]
-}
-\endqml
-
-If the list contains a single item, the square brackets may be omitted:
-
-\qml
-import QtQuick 2.0
-
-Item {
- states: State { name: "running" }
-}
-\endqml
-
-A \l list type property may be specified in an object declaration with the
-following syntax:
-
-\code
- [default] property list<<objectType>> propertyName
-\endcode
-
-and, like other property declarations, a property initialization may be
-combined with the property declaration with the following syntax:
-
-\code
- [default] property list<<objectType>> propertyName: <value>
-\endcode
-
-An example of list property declaration follows:
-
-\qml
-import QtQuick 2.0
-
-Rectangle {
- // declaration without initialization
- property list<Rectangle> siblingRects
-
- // declaration with initialization
- property list<Rectangle> childRects: [
- Rectangle { color: "red" },
- Rectangle { color: "blue"}
- ]
-}
-\endqml
-
-If you wish to declare a property to store a list of values which are not
-necessarily QML object-type values, you should declare a \l var property
-instead.
-
-
-\section4 Grouped Properties
-
-In some cases properties contain a logical group of sub-property attributes.
-These sub-property attributes can be assigned to using either the dot notation
-or group notation.
-
-For example, the \l Text type has a \l{Text::font.family}{font} group property. Below,
-the first \l Text object initializes its \c font values using dot notation,
-while the second uses group notation:
-
-\code
-Text {
- //dot notation
- font.pixelSize: 12
- font.b: true
-}
-
-Text {
- //group notation
- font { pixelSize: 12; b: true }
-}
-\endcode
-
-Grouped property types are basic types which have subproperties. Some of these
-basic types are provided by the QML language, while others may only be used if
-the Qt Quick module is imported. See the documentation about
-\l{QML Basic Types} for more information.
-
-
-\section3 Property Aliases
-
-Property aliases are properties which hold a reference to another property.
-Unlike an ordinary property definition, which allocates a new, unique storage
-space for the property, a property alias connects the newly declared property
-(called the aliasing property) as a direct reference to an existing property
-(the aliased property).
-
-A property alias declaration looks like an ordinary property definition, except
-that it requires the \c alias keyword instead of a property type, and the
-right-hand-side of the property declaration must be a valid alias reference:
-
-\code
-[default] property alias <name>: <alias reference>
-\endcode
-
-Unlike an ordinary property, an alias can only refer to a object, or the
-property of a object, that is within the scope of the \l{QML Object Types}
-{type} within which the alias is declared. It cannot contain arbitrary
-JavaScript expressions and it cannot refer to objects declared outside of
-the scope of its type. Also note the \e {alias reference} is not optional,
-unlike the optional default value for an ordinary property; the alias reference
-must be provided when the alias is first declared.
-
-For example, below is a \c Button type with a \c buttonText aliased property
-which is connected to the \c text object of the \l Text child:
-
-\qml
-// Button.qml
-import QtQuick 2.0
-
-Rectangle {
- property alias buttonText: textItem.text
-
- width: 100; height: 30; color: "yellow"
-
- Text { id: textItem }
-}
-\endqml
-
-The following code would create a \c Button with a defined text string for the
-child \l Text object:
-
-\qml
-Button { buttonText: "Click Me" }
-\endqml
-
-Here, modifying \c buttonText directly modifies the textItem.text value; it
-does not change some other value that then updates textItem.text. If
-\c buttonText was not an alias, changing its value would not actually change
-the displayed text at all, as property bindings are not bi-directional: the
-\c buttonText value would have changed if textItem.text was changed, but not
-the other way around.
-
-
-\section4 Considerations for Property Aliases
-
-Aliases are only activated once a component has been fully initialized. An
-error is generated when an uninitialized alias is referenced. Likewise,
-aliasing an aliasing property will also result in an error.
-
-\snippet qml/properties.qml alias complete
-
-When importing a \l{QML Object Types}{QML object type} with a property alias in
-the root object, however, the property appear as a regular Qt property and
-consequently can be used in alias references.
-
-It is possible for an aliasing property to have the same name as an existing
-property, effectively overwriting the existing property. For example,
-the following QML type has a \c color alias property, named the same as the
-built-in \l {Rectangle::color} property:
-
-\snippet qml/properties.qml alias overwrite
-
-Any object that use this type and refer to its \c color property will be
-referring to the alias rather than the ordinary \l {Rectangle::color} property.
-Internally, however, the red can correctly set its \c color
-property and refer to the actual defined property rather than the alias.
-
-
-\section3 Default Properties
-
-An object definition can have a single \e default property. A default property
-is the property to which a value is assigned if an object is declared within
-another object's definition without declaring it as a value for a particular
-property.
-
-Declaring a property with the optional \c default keyword marks it as the
-default property. For example, say there is a file MyLabel.qml with a default
-property \c someText:
-
-\qml
-// MyLabel.qml
-import QtQuick 2.0
-
-Text {
- default property var someText
-
- text: "Hello, " + someText.text
-}
-\endqml
-
-The \c someText value could be assigned to in a \c MyLabel object definition,
-like this:
-
-\qml
-MyLabel {
- Text { text: "world!" }
-}
-\endqml
-
-This has exactly the same effect as the following:
-
-\qml
-MyLabel {
- someText: Text { text: "world!" }
-}
-\endqml
-
-However, since the \c someText property has been marked as the default
-property, it is not necessary to explicitly assign the \l Text object
-to this property.
-
-You will notice that child objects can be added to any \l {Item}-based type
-without explicitly adding them to the \l {Item::children}{children} property.
-This is because the default property of \l Item is its \c data property, and
-any items added to this list for an \l Item are automatically added to its
-list of \l {Item::children}{children}.
-
-Default properties can be useful for reassigning the children of an item. See
-the \l{declarative/ui-components/tabwidget}{TabWidget example}, which uses a
-default property to automatically reassign children of the TabWidget as
-children of an inner ListView.
-
-
-\section3 Read-Only Properties
-
-An object declaration may define a read-only property using the \c readonly
-keyword, with the following syntax:
-
-\code
- readonly property <propertyType> <propertyName> : <initialValue>
-\endcode
-
-Read-only properties must be assigned a value on initialization. After a
-read-only property is initialized, it no longer possible to give it a value,
-whether from imperative code or otherwise.
-
-For example, the code in the \c Component.onCompleted block below is invalid:
-
-\qml
-Item {
- readonly property int someNumber: 10
-
- Component.onCompleted: someNumber = 20 // doesn't work, causes an error
-}
-\endqml
-
-\note A read-only property cannot also be a \l{Default Properties}{default} or
-\l {Property Aliases}{alias} property.
-
-
-\section3 Property Modifier Objects
-
-Properties can have
-\l{qtqml-cppintegration-definetypes.html#property-modifier-types}
-{property value modifier objects} associated with them.
-The syntax for declaring an instance of a property modifier type associated
-with a particular property is as follows:
-
-\code
-<PropertyModifierTypeName> on <propertyName> {
- // attributes of the object instance
-}
-\endcode
-
-It is important to note that the above syntax is in fact an
-\l{qtqml-syntax-basics.html#object-declarations}{object declaration} which
-will instantiate an object which acts on a pre-existing property.
-
-Certain property modifier types may only be applicable to specific property
-types, however this is not enforced by the language. For example, the
-\c NumberAnimation type provided by \c QtQuick will only animate
-numeric-type (such as \c int or \c real) properties. Attempting to use a
-\c NumberAnimation with non-numeric property will not result in an error,
-however the non-numeric property will not be animated. The behavior of a
-property modifier type when associated with a particular property type is
-defined by its implementation.
-
-
-\section2 Signal Attributes
-
-A signal is a notification from an object that some event has occurred: for
-example, a property has changed, an animation has started or stopped, or
-when an image has been downloaded. The \l MouseArea type, for example, has
-a \l {MouseArea::onClicked}{clicked} signal that is emitted when the user clicks
-within the mouse area.
-
-An object can be notified through a \l{Signal handler attributes}
-{signal handler} whenever it a particular signal is emitted. A signal handler
-is declared with the syntax \e on<Signal> where \e <Signal> is the name of the
-signal, with the first letter capitalized. The signal handler must be declared
-within the definition of the object that emits the signal, and the handler
-should contain the block of JavaScript code to be executed when the signal
-handler is invoked.
-
-For example, the \e onClicked signal handler below is declared within the
-\l MouseArea object definition, and is invoked when the \l MouseArea is
-clicked, causing a console message to be printed:
-
-\qml
-import QtQuick 2.0
-
-Item {
- width: 100; height: 100
-
- MouseArea {
- anchors.fill: parent
- onClicked: {
- console.log("Click!")
- }
- }
-}
-\endqml
-
-\section3 Defining Signal Attributes
-
-A signal may be defined for a type in C++ by registering a Q_SIGNAL of a class
-which is then registered with the QML type system. Alternatively, a custom
-signal for an object type may be defined in an object declaration in a QML
-document with the following syntax:
-
-\code
- signal <signalName>[([<type> <parameter name>[, ...]])]
-\endcode
-
-Attempting to declare two signals or methods with the same name in the same
-type block is an error. However, a new signal may reuse the name of an existing
-signal on the type. (This should be done with caution, as the existing signal
-may be hidden and become inaccessible.)
-
-Here are three examples of signal declarations:
-
-\qml
-import QtQuick 2.0
-
-Item {
- signal clicked
- signal hovered()
- signal actionPerformed(string action, var actionResult)
-}
-\endqml
-
-If the signal has no parameters, the "()" brackets are optional. If parameters
-are used, the parameter types must be declared, as for the \c string and \c var
-arguments for the \c actionPerformed signal above. The allowed parameter types
-are the same as those listed under \l {Defining Property Attributes} on this page.
-
-To emit a signal, invoke it as a method. Any relevant
-\l{Signal handler attributes}{signal handlers} will be invoked when the signal
-is emitted, and handlers can use the defined signal argument names to access
-the respective arguments.
-
-\section3 Property Change Signals
-
-QML types also provide built-in \e {property change signals} that are emitted
-whenever a property value changes, as previously described in the section on
-\l{Property attributes}{property attributes}. See the upcoming section on
-\l{Property change signal handlers}{property change signal handlers} for more
-information about why these signals are useful, and how to use them.
-
-
-\section2 Signal Handler Attributes
-
-Signal handlers are a special sort of \l{Method attributes}{method attribute},
-where the method implementation is invoked by the QML engine whenever the
-associated signal is emitted. Adding a signal to an object definition in QML
-will automatically add an associated signal handler to the object definition,
-which has, by default, an empty implementation. Clients can provide an
-implementation, to implement program logic.
-
-Consider the following \c SquareButton type, whose definition is provided in
-the \c SquareButton.qml file as shown below, with signals \c activated and
-\c deactivated:
-
-\qml
-// SquareButton.qml
-Rectangle {
- id: root
-
- signal activated(real xPosition, real yPosition)
- signal deactivated
-
- width: 100; height: 100
-
- MouseArea {
- anchors.fill: parent
- onPressed: root.activated(mouse.x, mouse.y)
- onRelased: root.deactivated()
- }
-}
-\endqml
-
-These signals could be received by any \c SquareButton objects in another QML
-file in the same directory, where implementations for the signal handlers are
-provided by the client:
-
-\qml
-// myapplication.qml
-SquareButton {
- onActivated: console.log("Activated at " + xPosition + "," + yPosition)
- onDeactivated: console.log("Deactivated!")
-}
-\endqml
-
-See the \l {Signal and Handler Event System} for more details on use of
-signals.
-
-\section3 Property Change Signal Handlers
-
-Signal handlers for property change signal take the syntax form
-\e on<Property>Changed where \e <Property> is the name of the property,
-with the first letter capitalized. For example, although the \l TextInput type
-documentation does not document a \c textChanged signal, this signal is
-implicitly available through the fact that \l TextInput has a
-\l {TextInput::text}{text} property and so it is possible to write an
-\c onTextChanged signal handler to be called whenever this property changes:
-
-\qml
-import QtQuick 2.0
-
-TextInput {
- text: "Change this!"
-
- onTextChanged: console.log("Text has changed to:", text)
-}
-\endqml
-
-
-\section2 Method Attributes
-
-A method of an object type is a function which may be called to perform some
-processing or trigger further events. A method can be connected to a signal so
-that it is automatically invoked whenever the signal is emitted. See
-\l {Signal and Handler Event System} for more details.
-
-\section3 Defining Method Attributes
-
-A method may be defined for a type in C++ by tagging a function of a class
-which is then registered with the QML type system with Q_INVOKABLE or by
-registering it as a Q_SLOT of the class. Alternatively, a custom method can
-be added to an object declaration in a QML document with the following syntax:
-
-\code
- function <functionName>([<parameterName>[, ...]]) { <body> }
-\endcode
-
-Methods can be added to a QML type in order to define standalone, reusable
-blocks of JavaScript code. These methods can be invoked either internally or
-by external objects.
-
-Unlike signals, method parameter types do not have to be declared as they
-default to the \c var type.
-
-Attempting to declare two methods or signals with the same name in the same
-type block is an error. However, a new method may reuse the name of an existing
-method on the type. (This should be done with caution, as the existing method
-may be hidden and become inaccessible.)
-
-Below is a \l Rectangle with a \c calculateHeight() method that is called when
-assigning the \c height value:
-
-\qml
-import QtQuick 2.0
-Rectangle {
- id: rect
-
- function calculateHeight() {
- return rect.width / 2;
- }
-
- width: 100
- height: calculateHeight()
-}
-\endqml
-
-If the method has parameters, they are accessible by name within the method.
-Below, when the \l MouseArea is clicked it invokes the \c moveTo() method which
-can then refer to the received \c newX and \c newY parameters to reposition the
-text:
-
-\qml
-import QtQuick 2.0
-
-Item {
- width: 200; height: 200
-
- MouseArea {
- anchors.fill: parent
- onClicked: label.moveTo(mouse.x, mouse.y)
- }
-
- Text {
- id: label
-
- function moveTo(newX, newY) {
- label.x = newX;
- label.y = newY;
- }
-
- text: "Move me!"
- }
-}
-\endqml
-
-
-\section2 Attached Properties and Attached Signal Handlers
-
-\e {Attached properties} and \e {attached signal handlers} are mechanisms that
-enable objects to be annotated with extra properties or signal handlers that
-are otherwise unavailable to the object. In particular, they allow objects to
-access properties or signals that are specifically relevant to the individual
-object.
-
-A QML type implementation may choose to create an \e {attaching type} with
-particular properties and signals. Instances of this type can then be created
-and \e attached to specific objects at run time, allowing those objects to
-access the properties and signals of the attaching type. These are accessed by
-prefixing the properties and respective signal handlers with the name of the
-attaching type.
-
-References to attached properties and handlers take the following syntax form:
-
-\code
-<AttachingType>.<propertyName>
-<AttachingType>.on<SignalName>
-\endcode
-
-For example, the \l ListView type has an attached property
-\l {ListView::isCurrentItem}{ListView.isCurrentItem} that is available to each delegate object in a
-ListView. This can be used by each individual delegate object to determine
-whether it is the currently selected item in the view:
-
-\qml
-import QtQuick 2.0
-
-ListView {
- width: 240; height: 320
- model: 3
- delegate: Rectangle {
- width: 100; height: 30
- color: ListView.isCurrentItem ? "red" : "yellow"
- }
-}
-\endqml
-
-In this case, the name of the \e {attaching type} is \c ListView and the
-property in question is \c isCurrentItem, hence the attached property is
-referred to as \c ListView.isCurrentItem.
-
-An attached signal handler is referred to in the same way. For example, the
-\c Component.isCompleted attached signal handler is commonly used to execute
-some JavaScript code when a component's creation process has been completed.
-In the example below, once the \l ListModel has been fully created, its
-\c Component.onCompleted signal handler will automatically be invoked to
-populate the model:
-
-\qml
-import QtQuick 2.0
-
-ListView {
- width: 240; height: 320
- model: ListModel {
- id: listModel
- Component.onCompleted: {
- for (var i = 0; i < 10; i++)
- listModel.append({"Name": "Item " + i})
- }
- }
- delegate: Text { text: index }
-}
-\endqml
-
-Since the name of the \e {attaching type} is \c Component and that type has a
-\c completed signal, the attached signal handler is referred to as
-\c Component.isCompleted.
-
-
-\section3 A Note About Accessing Attached Properties and Signal Handlers
-
-A common error is to assume that attached properties and signal handlers are
-directly accessible from the children of the object to which these attributes
-have been attached. This is not the case. The instance of the
-\e {attaching type} is only attached to specific objects, not to the object
-and all of its children.
-
-For example, below is a modified version of the earlier example involving
-attached properties. This time, the delegate is an \l Item and the colored
-\l Rectangle is a child of that item:
-
-\qml
-import QtQuick 2.0
-
-ListView {
- width: 240; height: 320
- model: 3
- delegate: Item {
- width: 100; height: 30
-
- Rectangle {
- width: 100; height: 30
- color: ListView.isCurrentItem ? "red" : "yellow" // WRONG! This won't work.
- }
- }
-}
-\endqml
-
-This does not work as expected because \c ListView.isCurrentItem is attached
-\e only to the root delegate object, and not its children. Since the
-\l Rectangle is a child of the delegate, rather than being the delegate itself,
-it cannot access the \c isCurrentItem attached property as
-\c ListView.isCurrentItem. So instead, the rectangle should access
-\c isCurrentItem through the root delegate:
-
-\qml
-ListView {
- //....
- delegate: Item {
- id: delegateItem
- width: 100; height: 30
-
- Rectangle {
- width: 100; height: 30
- color: delegateItem.ListView.isCurrentItem ? "red" : "yellow" // correct
- }
- }
-}
-\endqml
-
-Now \c delegateItem.ListView.isCurrentItem correctly refers to the
-\c isCurrentItem attached property of the delegate.
-
-*/
diff --git a/src/qml/doc/src/syntax/propertybinding.qdoc b/src/qml/doc/src/syntax/propertybinding.qdoc
deleted file mode 100644
index 6803901efd..0000000000
--- a/src/qml/doc/src/syntax/propertybinding.qdoc
+++ /dev/null
@@ -1,189 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Free Documentation License Usage
-** 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. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: http://www.gnu.org/copyleft/fdl.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
-\page qtqml-syntax-propertybinding.html
-\title Property Binding
-\brief binding object properties
-
-To make the fullest use of QML and its built-in support for implementing dynamic object behavioral changes, most QML objects will use \e {property binding}. This is a core feature of QML that allows objects to automatically update their properties in response to changing attributes in other objects or the occurence of some external event.
-
-When an object's property is assigned a value, it can either be assigned a static value, or \e bound to a JavaScript expression. In the first case, the property's value will not change unless a new value is assigned to the property. In the latter case, a \e {property binding} is created and the property's value is automatically updated by the QML engine whenever the value of the evaluated expression changes.
-
-
-\section1 Overview
-
-To create a property binding, a property is assigned an expression that evaluates to the desired value. At its simplest, an expression may simply be a reference to another object's property. Take the following example, where the blue \l Rectangle's \c height is bound to the height of its parent:
-
-\qml
-Rectangle {
- width: 200; height: 200
-
- Rectangle {
- width: 100; height: parent.height
- color: "blue"
- }
-}
-\endqml
-
-Whenever the \c height of the parent item changes, the \c height of the blue rectangle will update to be of the same value.
-
-Furthermore, a binding can contain any valid JavaScript expression or
-statement, as QML uses a standards compliant JavaScript engine. Below are
-valid bindings that could be substituted for the \c height binding from the
-above example:
-
-\code
-height: parent.height / 2
-
-height: Math.min(parent.width, parent.height)
-
-height: parent.height > 100 ? parent.height : parent.height/2
-
-height: {
- if (parent.height > 100)
- return parent.height
- else
- return parent.height / 2
-}
-
-height: someMethodThatReturnsHeight()
-\endcode
-
-Whenever the value of \c parent.height changes, the QML engine will re-evaluate the above expression and assign the blue rectangle's \c width property with the appropriate updated value.
-
-Bindings can access object properties, call methods and use built-in JavaScript objects such as \c Date and \c Math. Here is an example with various valid bindings:
-
-\qml
-Column {
- width: 200
- height: 200
-
- Rectangle {
- width: Math.max(bottomRect.width, parent.width/2)
- height: (parent.height / 3) + 10
- color: "yellow"
-
- TextInput {
- id: myTextInput
- text: "Hello QML!"
- }
- }
-
- Rectangle {
- id: bottomRect
- width: 100
- height: 50
- color: myTextInput.text.length <= 10 ? "red" : "blue"
- }
-}
-\endqml
-
-While syntactically bindings can be of arbitrary complexity, if a binding starts to become overly complex - such as involving multiple lines, or imperative loops - it may be better to refactor the component entirely, or at least factor the binding out into a separate function.
-
-
-\keyword qml-javascript-assignment
-\section1 Creating Property Bindings from JavaScript
-
-Once a property has been bound to an expression, the property is set to be automatically updated as necessary. However, be aware that if the property is later assigned a static value from a JavaScript statement, this will remove the binding.
-
-For example, the \c height of the \l Rectangle below is initially bound to be twice its \c width. However, when the space key is pressed, the \c height value is changed to be three times its \c width. At this point, the \c height is assigned the currently evaluated result of \c width*3 and \e {the height will no longer be automatically updated whenever the width changes}. The assignment of the static value removes the binding.
-
-\qml
-import QtQuick 2.0
-
-Rectangle {
- width: 100
- height: width * 2
-
- focus: true
- Keys.onSpacePressed: {
- height = width * 3
- }
-}
-\endqml
-
-If the intention is to remove the binding, then this is not a problem. However if the intention is to create a new binding of \c width*3 then the property must be assigned a Qt.binding() value instead. This is done by passing a function to Qt.binding() that returns the desired result:
-
-\qml
-import QtQuick 2.0
-
-Rectangle {
- width: 100
- height: width * 2
-
- focus: true
- Keys.onSpacePressed: {
- height = Qt.binding(function() { return width * 3 })
- }
-}
-\endqml
-
-Now when the space key is pressed, a new binding of \c width*3 is assigned, instead of simply removing the initial binding.
-
-
-\section2 Using \c this with Property Binding
-
-When creating a property binding from JavaScript, QML allows the use of the \c
-this keyword to refer to the object to which the property binding will be
-assigned. This allows one to explicitly refer to a property within an object
-when there may be ambiguity about the exact property that should be used for the
-binding.
-
-For example, the \c Component.onCompleted handler below is defined within the
-scope of the \l Item, and references to \c width within this scope would refer
-to the \l Item's width, rather than that of the \l Rectangle. To bind the \l
-Rectangle's \c height to its own \c width, the function passed to Qt.binding()
-needs to explicitly refer to \c this.width rather than just \c width.
-
-\qml
-Item {
- width: 500
- height: 500
-
- Rectangle {
- id: rect
- width: 100
- color: "yellow"
- }
-
- Component.onCompleted: {
- rect.height = Qt.binding(function() { return this.width * 2 })
- console.log("rect.height = " + rect.height) // prints 200, not 1000
- }
-}
-\endqml
-
-In this case, the function could also have referred to \c rect.width rather than
-\c this.width.
-
-Note that the value of \c this is not defined outside of its use in property binding.
-See \l {JavaScript Environment Restrictions} for details.
-
-
-*/
-
diff --git a/src/qml/doc/src/syntax/signals.qdoc b/src/qml/doc/src/syntax/signals.qdoc
deleted file mode 100644
index 6c90ddcf0a..0000000000
--- a/src/qml/doc/src/syntax/signals.qdoc
+++ /dev/null
@@ -1,297 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Free Documentation License Usage
-** 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. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: http://www.gnu.org/copyleft/fdl.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
-\page qtqml-syntax-signals.html
-\ingroup qml-features
-
-\title Signal and Handler Event System
-\brief the event sytem in QML
-
-Application and user interface components need to communicate with each other. For
-example, a button needs to know that the user has clicked on it.
-The button may change colors to indicate its state or perform some logic. As
-well, application needs to know whether the user is clicking the button. The
-application may need to relay this clicking event to other applications.
-
-QML has a signal and handler mechanism, where the \e signal is the event
-and the signal is responded to through a \e {signal handler}. When a signal
-is emitted, the corresponding signal handler is invoked. Placing logic such as scripts or other
-operations in the handler allows the component to respond to the event.
-
-\keyword qml-signals-and-handlers
-\section1 Receiving Signals with Signal Handlers
-
-To receive a notification when a particular signal is emitted for a particular object, the object definition should declare a signal handler named \e on<Signal> where \e <Signal> is the name of the signal, with the first letter capitalized. The signal handler should contain the JavaScript code to be executed when the signal handler is invoked.
-
-For example, the \l MouseArea type from the \c QtQuick module has a \c clicked signal that is emitted whenever the mouse is clicked within the area. Since the signal name is \c clicked, the signal handler for receiving this signal should be named \c onClicked. In the example below, whenever the mouse area is clicked, the \c onClicked handler is invoked, applying a random color to the \l Rectangle:
-
-\qml
-import QtQuick 2.0
-
-Rectangle {
- id: rect
- width: 100; height: 100
-
- MouseArea {
- anchors.fill: parent
- onClicked: {
- rect.color = Qt.rgba(Math.random(), Math.random(), Math.random(), 1);
- }
- }
-}
-\endqml
-
-Looking at the \l MouseArea documentation, you can see the \l {MouseArea::onClicked}{clicked} signal is emitted with a parameter named \c mouse which is a \l MouseEvent object that contains further details about the mouse click event. This name can be referred to in our \c onClicked handler to access this parameter. For example, the \l MouseEvent type has \c x and \c y coordinates that allows us to print out the exact location where the mouse was clicked:
-
-\qml
-import QtQuick 2.0
-
-Rectangle {
- id: rect
- width: 100; height: 100
-
- MouseArea {
- anchors.fill: parent
- onClicked: {
- rect.color = Qt.rgba(Math.random(), Math.random(), Math.random(), 1);
-
- // access 'mouse' parameter
- console.log("Clicked mouse at", mouse.x, mouse.y)
- }
- }
-}
-\endqml
-
-
-\section2 Property Change Signal Handlers
-
-A signal is automatically emitted when the value of a QML property changes. This type of signal is a \e {property change signal} and signal handlers for these signals are written in the form \e on<Property>Changed where \e <Property> is the name of the property, with the first letter capitalized.
-
-For example, the \l MouseArea type has a \l {MouseArea::pressed}{pressed} property. To receive a notification whenever this property changes, write a signal handler named \c onPressedChanged:
-
-\qml
-import QtQuick 2.0
-
-Rectangle {
- id: rect
- width: 100; height: 100
-
- MouseArea {
- anchors.fill: parent
- onPressedChanged: {
- console.log("Mouse area is pressed?", pressed)
- }
- }
-}
-\endqml
-
-Even though the \l MouseArea documentation does not document a signal handler named \c onPressedChanged, the signal is implicitly provided by the fact that the \c pressed property exists.
-
-
-\section2 Using the Connections Type
-
-In some cases it may be desirable to access a signal outside of the object that emits it. For these purposes, the QtQuick module provides the \l Connections type for connecting to signals of arbitrary objects. A \l Connections object can receive any signal from its specified \l {Connections::target}{target}.
-
-For example, the \c onClicked handler in the earlier example could have been received by the root \l Rectangle instead, by placing the \c onClicked handler in a \l Connections object that has its \l {Connections::target}{target} set to the \l MouseArea:
-
-\qml
-import QtQuick 2.0
-
-Rectangle {
- id: rect
- width: 100; height: 100
-
- MouseArea {
- id: mouseArea
- anchors.fill: parent
- }
-
- Connections {
- target: mouseArea
- onClicked: {
- rect.color = Qt.rgba(Math.random(), Math.random(), Math.random(), 1);
- }
- }
-}
-\endqml
-
-
-\section2 Attached Signal Handlers
-
-An \l {attached signal handler} is a signal handler that receives a signal from an \e {attaching type} rather than the object within which the handler is declared.
-
-For example, \c \l {Component::isCompleted}{Component.isCompleted} is an attached signal handler. This handler is often used to execute some JavaScript code when its creation process has been completed, as in the example below:
-
-\qml
-import QtQuick 2.0
-
-Rectangle {
- width: 200; height: 200
- color: Qt.rgba(Qt.random(), Qt.random(), Qt.random(), 1)
-
- Component.onCompleted: {
- console.log("The rectangle's color is", color)
- }
-}
-\endqml
-
-The \c onCompleted handler is not responding to some \c completed signal from the \l Rectangle type. Instead, an object of the \c Component \e {attaching type} with a \c completed signal has automatically been \e attached to the \l Rectangle object by the QML engine, and the engine emits this signal when the object is fully created, thus triggering the \c Component.onCompleted signal handler.
-
-Attached signal handlers allow objects to be notified of particular signals that are significant to each individual object. If there was no \c Component.onCompleted attached signal handler, for example, then an object could not receive this notification without registering for some special signal from some special object. The \e {attached signal handler} mechanism enables objects to receive particular signals without these extra processes.
-
-See \l {Attached properties and attached signal handlers} for more information on attached signal handlers.
-
-
-\section1 Adding Signals to Custom QML Types
-
-Signals can be added to custom QML types through the \c signal keyword.
-
-The syntax for defining a new signal is:
-
-\tt{signal <name>[([<type> <parameter name>[, ...]])]}
-
-A signal is emitted by invoking the signal as a method.
-
-For example, say the code below is defined in a file named \c SquareButton.qml. The root \l Rectangle object has an \c activated signal. When the child \l MouseArea is clicked, it emits the parent's \c activated signal with the coordinates of the mouse click:
-
-\qml
-// SquareButton.qml
-Rectangle {
- id: root
-
- signal activated(real xPosition, real yPosition)
-
- width: 100; height: 100
-
- MouseArea {
- anchors.fill: parent
- onPressed: root.activated(mouse.x, mouse.y)
- }
-}
-\endqml
-
-Now any objects of the \c SquareButton can connect to the \c activated signal using an \c onActivated signal handler:
-
-\qml
-// myapplication.qml
-SquareButton {
- onActivated: console.log("Activated at " + xPosition + "," + yPosition)
-}
-\endqml
-
-See \l {Signal Attributes} for more details on writing signals for custom QML types.
-
-
-\keyword qml-connect-signals-to-method
-\section1 Connecting Signals to Methods and Signals
-
-Signal objects have a \c connect() method to a connect a signal either to a
-method or another signal. When a signal is connected to a method, the method is
-automatically invoked whenever the signal is emitted. This mechanism enables a
-signal to be received by a method instead of a signal handler.
-
-Below, the \c messageReceived signal is connected to three methods using the \c connect() method:
-
-\qml
-Rectangle {
- id: relay
-
- signal messageReceived(string person, string notice)
-
- Component.onCompleted: {
- relay.messageReceived.connect(sendToPost)
- relay.messageReceived.connect(sendToTelegraph)
- relay.messageReceived.connect(sendToEmail)
- relay.messageReceived("Tom", "Happy Birthday")
- }
-
- function sendToPost(person, notice) {
- console.log("Sending to post: " + person + ", " + notice)
- }
- function sendToTelegraph(person, notice) {
- console.log("Sending to telegraph: " + person + ", " + notice)
- }
- function sendToEmail(person, notice) {
- console.log("Sending to email: " + person + ", " + notice)
- }
-}
-\endqml
-
-In many cases it is sufficient to receive signals through signal handlers rather than using the connect() function. However, using the \c connect method allows a signal to be received by multiple methods as shown above, which would not be possible with signal handlers as they must be uniquely named. Also, the \c connect method is useful when connecting signals to \l {Dynamic QML Object Creation from JavaScript}{dynamically created objects}.
-
-There is a corresponding \c disconnect() method for removing connected signals:
-
-\qml
-Rectangle {
- id: relay
- //...
-
- function removeTelegraphSignal() {
- relay.messageReceived.disconnect(sendToTelegraph)
- }
-}
-\endqml
-
-\section3 Signal to Signal Connect
-
-By connecting signals to other signals, the \c connect() method can form different
-signal chains.
-
-\qml
-Rectangle {
- id: forwarder
- width: 100; height: 100
-
- signal send()
- onSend: console.log("Send clicked")
-
- MouseArea {
- id: mousearea
- anchors.fill: parent
- onClicked: console.log("MouseArea clicked")
- }
-
- Component.onCompleted: {
- mousearea.clicked.connect(send)
- }
-}
-\endqml
-
-
-Whenever the \l MouseArea \c clicked signal is emitted, the \c send
-signal will automatically be emitted as well.
-
-\code
-output:
- MouseArea clicked
- Send clicked
-\endcode
-
-
-*/
-