summaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/src/declarative/animation.qdoc9
-rw-r--r--doc/src/declarative/declarativeui.qdoc4
-rw-r--r--doc/src/declarative/dynamicobjects.qdoc25
-rw-r--r--doc/src/declarative/elements.qdoc2
-rw-r--r--doc/src/declarative/extending.qdoc62
-rw-r--r--doc/src/declarative/globalobject.qdoc12
-rw-r--r--doc/src/declarative/qdeclarativemodels.qdoc22
-rw-r--r--doc/src/declarative/qtdeclarative.qdoc48
8 files changed, 120 insertions, 64 deletions
diff --git a/doc/src/declarative/animation.qdoc b/doc/src/declarative/animation.qdoc
index 2b75211..7e0a787 100644
--- a/doc/src/declarative/animation.qdoc
+++ b/doc/src/declarative/animation.qdoc
@@ -58,7 +58,8 @@ types listed above. If the property you are animating is a number or color, you
NumberAnimation or ColorAnimation. These elements don't add any additional functionality,
but will help enforce type correctness and are slightly more efficient.
-A property animation can be specified as a value source. This is especially useful for repeating animations.
+A property animation can be specified as a value source using the \e Animation \bold on \e property syntax. This is especially useful
+for repeating animations.
The following example creates a bouncing effect:
\qml
@@ -70,7 +71,7 @@ Rectangle {
source: "qt-logo.png"
x: 60-img.width/2
y: 0
- y: SequentialAnimation {
+ SequentialAnimation on y {
repeat: true
NumberAnimation { to: 200-img.height; easing.type: "OutBounce"; duration: 2000 }
PauseAnimation { duration: 1000 }
@@ -93,7 +94,7 @@ Rectangle {
Rectangle {
color: "red"
width: 50; height: 50
- x: NumberAnimation { to: 50; }
+ NumberAnimation on x { to: 50; }
}
}
\endqml
@@ -226,7 +227,7 @@ Rectangle {
id: redRect
color: "red"
width: 100; height: 100
- x: Behavior { NumberAnimation { duration: 300; easing.type: "InOutQuad" } }
+ Behavior on x { NumberAnimation { duration: 300; easing.type: "InOutQuad" } }
}
\endqml
diff --git a/doc/src/declarative/declarativeui.qdoc b/doc/src/declarative/declarativeui.qdoc
index 4b61bd9..ed63367 100644
--- a/doc/src/declarative/declarativeui.qdoc
+++ b/doc/src/declarative/declarativeui.qdoc
@@ -68,7 +68,7 @@ internet-enabled applications like a \l {http://www.flickr.com}{Flickr} photo br
Qt Declarative builds on \l {QML for Qt programmers}{Qt's existing strengths}.
QML can be be used to incrementally extend an existing application or to build
-completely new applications. QML is fully \l {Extending QML}{extensible from C++}.
+completely new applications. QML is fully \l {Extending QML in C++}{extensible from C++}.
\section1 Getting Started:
\list
@@ -100,7 +100,7 @@ completely new applications. QML is fully \l {Extending QML}{extensible from C+
\list
\o \l {QML Elements}
\o \l {QML Global Object}
-\o \l {Extending QML}
+\o \l {Extending QML in C++}
\o \l {QML Internationalization}
\o \l {QtDeclarative Module}
\o \l {Debugging QML}
diff --git a/doc/src/declarative/dynamicobjects.qdoc b/doc/src/declarative/dynamicobjects.qdoc
index 033c0d1..b2e3f90 100644
--- a/doc/src/declarative/dynamicobjects.qdoc
+++ b/doc/src/declarative/dynamicobjects.qdoc
@@ -76,25 +76,25 @@ the component. Example QML script is below. Remember that QML files that might b
\code
var component;
var sprite;
- function finishCreation(){
- if(component.isReady()){
+ function finishCreation() {
+ if(component.isReady()) {
sprite = component.createObject();
- if(sprite == 0){
+ if(sprite == 0) {
// Error Handling
- }else{
+ } else {
sprite.parent = page;
sprite.x = 200;
//...
}
- }else if(component.isError()){
+ } else if(component.isError()) {
// Error Handling
}
}
component = createComponent("Sprite.qml");
- if(component.isReady()){
+ if(component.isReady()) {
finishCreation();
- }else{
+ } else {
component.statusChanged.connect(finishCreation);
}
\endcode
@@ -104,10 +104,10 @@ the component. Example QML script is below. Remember that QML files that might b
\code
component = createComponent("Sprite.qml");
sprite = component.createObject();
- if(sprite == 0){
+ if(sprite == 0) {
// Error Handling
console.log(component.errorsString());
- }else{
+ } else {
sprite.parent = page;
sprite.x = 200;
//...
@@ -122,7 +122,7 @@ If the QML does not exist until runtime, you can create a QML item from
a string of QML using the createQmlObject function, as in the following example:
\code
- newObject = createQmlObject('import Qt 4.6; Rectangle {color: "red"; width: 20; height: 20}',
+ newObject = createQmlObject('import Qt 4.6; Rectangle { color: "red"; width: 20; height: 20 }',
targetItem, "dynamicSnippet1");
\endcode
The first argument is the string of QML to create. Just like in a new file, you will need to
@@ -158,11 +158,12 @@ argument, which is an approximate delay in ms and which defaults to zero. This
allows you to wait until the completion of an animation or transition. An example:
\code
- Component{ id:fadesOut
+ Component {
+ id: fadesOut
Rectangle{
id: rect
width: 40; height: 40;
- opacity: NumberAnimation{from:1; to:0; duration: 1000;}
+ NumberAnimation on opacity { from:1; to:0; duration: 1000 }
Component.onCompleted: rect.destroy(1000);
}
}
diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc
index 67aadcf..75f8b97 100644
--- a/doc/src/declarative/elements.qdoc
+++ b/doc/src/declarative/elements.qdoc
@@ -76,6 +76,7 @@ The following table lists the QML elements provided by the Qt Declarative module
\o \l ParallelAnimation
\o \l PauseAnimation
\o \l ParentAnimation
+\o \l AnchorAnimation
\o \l PropertyAction
\o \l ParentAction
\o \l ScriptAction
@@ -93,7 +94,6 @@ The following table lists the QML elements provided by the Qt Declarative module
\o \l VisualDataModel
\o \l Package
\o \l XmlListModel and XmlRole
-\o \l WorkerListModel
\endlist
\o
diff --git a/doc/src/declarative/extending.qdoc b/doc/src/declarative/extending.qdoc
index 5aaa7bd..0ae4f7d 100644
--- a/doc/src/declarative/extending.qdoc
+++ b/doc/src/declarative/extending.qdoc
@@ -41,7 +41,7 @@
/*!
\page qml-extending.html
-\title Extending QML
+\title Extending QML in C++
The QML syntax declaratively describes how to construct an in memory object
tree. In Qt, QML is mainly used to describe a visual scene graph, but it is
@@ -67,21 +67,23 @@ that derive from QObject.
The QML engine has no intrinsic knowledge of any class types. Instead the
programmer must define the C++ types, and their corresponding QML name.
-Custom C++ types are made available to QML using these two macros:
+Custom C++ types are declared QML types using a macro and a template function:
\quotation
+
\code
#define QML_DECLARE_TYPE(T)
-#define QML_REGISTER_TYPE(URI,VMAJ,VMIN,QDeclarativeName,T)
+template<typename T>
+int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
\endcode
-Register the C++ type \a T with the QML system, and make it available in QML
-under the name \a QDeclarativeName in library URI version VMAJ.VMIN.
-\a T and \a QDeclarativeName may be the same.
+Calling qmlRegisterType() registers the C++ type \a T with the QML system, and makes it available in QML
+under the name \a qmlName in library \a uri version \a versionMajor.versionMinor.
+The \a qmlName can be the same as the C++ type name.
Generally the QML_DECLARE_TYPE() macro should be included immediately following
-the type declaration (usually in its header file), and the QML_REGISTER_TYPE()
-macro called by the implementation.
+the type declaration (usually in its header file), and the template function qmlRegisterType()
+called by the implementation.
Type \a T must be a concrete type that inherits QObject and has a default
constructor.
@@ -147,19 +149,20 @@ property can be assigned.
QML also supports assigning Qt interfaces. To assign to a property whose type
is a Qt interface pointer, the interface must also be registered with QML. As
they cannot be instantiated directly, registering a Qt interface is different
-from registering a new QML type. The following macros are used instead:
+from registering a new QML type. The following macro and function are used instead:
\quotation
\code
- #define QML_DECLARE_INTERFACE(T)
- #define QML_REGISTER_INTERFACE(T)
+#define QML_DECLARE_INTERFACE(T)
+template<typename T>
+int qmlRegisterInterface(const char *typeName)
\endcode
-Register the C++ interface \a T with the QML system.
+Registers the C++ interface \a T with the QML system as \a typeName.
Generally the QML_DECLARE_INTERFACE() macro should be included immediately
following the interface declaration (usually in its header file), and the
-QML_REGISTER_INTERFACE() macro called by the implementation.
+qmlRegisterInterface() template function called by the implementation.
Following registration, QML can coerce objects that implement this interface
for assignment to appropriately typed properties.
@@ -174,7 +177,7 @@ The guest property declaration looks like this:
\snippet examples/declarative/extending/properties/birthdayparty.h 2
-\l {Extending QML - Object and List Property Types Example} shows the complete
+\l {Extending QML in C++ - Object and List Property Types Example} shows the complete
code used to create the \c BirthdayParty type.
\section1 Inheritance and Coercion
@@ -192,25 +195,26 @@ type used in the previous section, but the assignment is valid as both the Boy
and Girl objects inherit from Person.
To assign to a property, the property's type must have been registered with QML.
-Both the QML_REGISTER_TYPE() and QML_REGISTER_INTERFACE() macros already shown can
-be used to register a type with QML. Additionally, if a type that acts purely
+Both the qmlRegisterType() and qmlRegisterInterface() template functions already
+shown can be used to register a type with QML. Additionally, if a type that acts purely
as a base class that cannot be instantiated from QML needs to be
-registered these macros can be used:
+registered these macro and function can be used:
\quotation
\code
#define QML_DECLARE_TYPE(T)
- #define QML_REGISTER_NOCREATE_TYPE(T)
+ template<typename T>
+ int qmlRegisterType()
\endcode
-Register the C++ type \a T with the QML system. QML_REGISTER_NOCREATE_TYPE()
-differs from QML_REGISTER_TYPE() in that it does not define a mapping between the
+Registers the C++ type \a T with the QML system. The parameterless call to the template
+function qmlRegisterType() does not define a mapping between the
C++ class and a QML element name, so the type is not instantiable from QML, but
it is available for type coercion.
Generally the QML_DECLARE_TYPE() macro should be included immediately following
the type declaration (usually in its header file), and the
-QML_REGISTER_NOCREATE_TYPE() macro called from the implementation.
+qmlRegisterType() template function called from the implementation.
Type \a T must inherit QObject, but there are no restrictions on whether it is
concrete or the signature of its constructor.
@@ -220,7 +224,7 @@ QML will automatically coerce C++ types when assigning to either an object
property, or to a list property. Only if coercion fails does an assignment
error occur.
-\l {Extending QML - Inheritance and Coercion Example} shows the complete
+\l {Extending QML in C++ - Inheritance and Coercion Example} shows the complete
code used to create the \c Boy and \c Girl types.
\section1 Default Property
@@ -252,7 +256,7 @@ refer to a property declared in the class itself, or a property inherited from a
base class.
\endquotation
-\l {Extending QML - Default Property Example} shows the complete code used to
+\l {Extending QML in C++ - Default Property Example} shows the complete code used to
specify a default property.
\section1 Grouped Properties
@@ -277,7 +281,7 @@ property block - in this case the size, color, brand and price properties.
Grouped property blocks may declared and accessed be recusively.
-\l {Extending QML - Grouped Properties Example} shows the complete code used to
+\l {Extending QML in C++ - Grouped Properties Example} shows the complete code used to
implement the \c shoe property grouping.
\section1 Attached Properties
@@ -369,7 +373,7 @@ creating it if it does not already exist. If \a create is false, the attachment
object will only be returned if it has previously been created.
\endquotation
-\l {Extending QML - Attached Properties Example} shows the complete code used to
+\l {Extending QML in C++ - Attached Properties Example} shows the complete code used to
implement the rsvp attached property.
\section1 Memory Management and QVariant types
@@ -431,7 +435,7 @@ listed in \l {Adding Types}, as well registered object types are permitted as
signal parameter types. Using other types is not an error, but the parameter
value will not be accessible from script.
-\l {Extending QML - Signal Support Example} shows the complete code used to
+\l {Extending QML in C++ - Signal Support Example} shows the complete code used to
implement the onPartyStarted signal property.
\section1 Property Value Sources
@@ -478,7 +482,7 @@ to assign it normally, as though it were a regular QML type. Only if this
assignment fails does the engine call the setTarget() method. This allows
the type to also be used in contexts other than just as a value source.
-\l {Extending QML - Property Value Source Example} shows the complete code used
+\l {Extending QML in C++ - Property Value Source Example} shows the complete code used
implement the HappyBirthday property value source.
\section1 Property Binding
@@ -550,7 +554,7 @@ The CONSTANT attribute should only be used for properties whose value is set,
and finalized, only in the class constructor. All other properties that want
to be used in bindings should have a NOTIFY signal instead.
-\l {Extending QML - Binding Example} shows the BirthdayParty example updated to
+\l {Extending QML in C++ - Binding Example} shows the BirthdayParty example updated to
include NOTIFY signals for use in binding.
\section1 Extension Objects
@@ -623,7 +627,7 @@ public:
\title Extending types from QML
Many of the elements available for use in QML are implemented in
-\l {Extending QML}{C++}. These types are know as "core types". QML
+\l {Extending QML in C++}{C++}. These types are know as "core types". QML
allows programmers to build new, fully functional elements without using C++.
Existing core types can be extended, and new types defined entirely in the QML
language.
diff --git a/doc/src/declarative/globalobject.qdoc b/doc/src/declarative/globalobject.qdoc
index 4b1c7d3..9f6be12 100644
--- a/doc/src/declarative/globalobject.qdoc
+++ b/doc/src/declarative/globalobject.qdoc
@@ -182,18 +182,6 @@ This function returns a color 50% darker than \c baseColor. See QColor::darker()
\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.closestAngle(number fromAngle, number toAngle)
-This function returns an equivalent angle to toAngle, such that the difference between fromAngle and toAngle is never more than 180 degrees. This is useful when animating angles using a NumberAnimation, which does not know about equivalent angles, when you always want to take the shortest path.
-
-For example, the following would rotate myItem counterclockwise from 350 degrees to 10 degrees, for a total of 340 degrees of rotation.
-\qml
-NumberAnimation { target: myItem; property: "rotation"; from: 350; to: 10 }
-\endqml
-
-while the following would rotate myItem clockwise from 350 degrees to 370 degrees (which is visually equivilant to 10 degrees), for a total of 20 degrees of rotation.
-\qml
-NumberAnimation { target: myItem; property: "rotation"; from: 350; to: Qt.closetAngle(350, 10) }
-\endqml
\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.
diff --git a/doc/src/declarative/qdeclarativemodels.qdoc b/doc/src/declarative/qdeclarativemodels.qdoc
index c0e028e..e80824d 100644
--- a/doc/src/declarative/qdeclarativemodels.qdoc
+++ b/doc/src/declarative/qdeclarativemodels.qdoc
@@ -191,6 +191,23 @@ will be positioned by the view.
\section2 QAbstractItemModel
QAbstractItemModel provides the roles set via the QAbstractItemModel::setRoleNames() method.
+The default role names set by Qt are:
+
+\table
+\header
+\o Qt Role
+\o QML Role Name
+\row
+\o Qt::DisplayRole
+\o display
+\row
+\o Qt::DecorationRole
+\o decoration
+\endtable
+
+QAbstractItemModel presents a heirachy of tables. Views currently provided by QML
+can only display list data. In order to display child lists of a heirachical model
+use the VisualDataModel element with \e rootIndex set to a parent node.
\section2 QStringList
@@ -198,9 +215,6 @@ QAbstractItemModel provides the roles set via the QAbstractItemModel::setRoleNam
QStringList provides the contents of the list via the \e modelData role:
\table
-\header
-\o
-\o
\row
\o
\code
@@ -208,7 +222,7 @@ QStringList provides the contents of the list via the \e modelData role:
QStringList dataList;
dataList.append("Fred");
dataList.append("Ginger");
-dataList.appenf("Skipper");
+dataList.append("Skipper");
QDeclarativeContext *ctxt = view.rootContext();
ctxt->setContextProperty("myModel", QVariant::fromValue(&dataList));
diff --git a/doc/src/declarative/qtdeclarative.qdoc b/doc/src/declarative/qtdeclarative.qdoc
index 41d6338..b43d0ec 100644
--- a/doc/src/declarative/qtdeclarative.qdoc
+++ b/doc/src/declarative/qtdeclarative.qdoc
@@ -65,3 +65,51 @@ For more information on the Qt Declarative module, see the
\l{declarativeui.html}{Declarative UI} documentation.
*/
+
+
+/*!
+ \macro QML_DECLARE_TYPE(T)
+ \relates QDeclarativeEngine
+
+ yada yada yada
+
+*/
+
+
+/*!
+ \fn int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
+ \relates QDeclarativeEngine
+
+ This template function registers the C++ type \a T with the QML system, and make it available in
+ QML under the name \a qmlName in the import library \a uri version \a versionMajor.versionMajor.
+
+ Returns the QML type id.
+
+ Example: Register the C++ class \c MinehuntGame as QML type \c Game version 0.1 in the import
+ library \c MinehuntCore:
+
+ \code
+ qmlRegisterType<MinehuntGame>("MinehuntCore", 0, 1, "Game");
+ \endcode
+
+*/
+
+/*!
+ \fn int qmlRegisterType()
+ \relates QDeclarativeEngine
+ \overload
+
+ This template function registers the C++ type \a T with the QML system. Instances of this type cannot
+ be created from the QML system.
+
+ Returns the QML type id.
+*/
+
+/*! \fn int qmlRegisterInterface(const char *typeName)
+ \relates QDeclarativeEngine
+
+ This template function registers the C++ type \a T as interface with the QML system, under the name
+ \a typeName.
+
+ Returns the QML type id.
+ */