From b4b0bdda668e9845623995c788d88a774dd52d98 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Tue, 27 Jul 2010 10:30:07 +1000 Subject: Document 'this' as undefined in QML Task-number: QTBUG-12396 Reviewed-by: Aaron Kennedy --- doc/src/declarative/javascriptblocks.qdoc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/doc/src/declarative/javascriptblocks.qdoc b/doc/src/declarative/javascriptblocks.qdoc index c41e38e..18da3d2 100644 --- a/doc/src/declarative/javascriptblocks.qdoc +++ b/doc/src/declarative/javascriptblocks.qdoc @@ -236,6 +236,31 @@ This restriction exists as the QML environment is not yet fully established. To run code after the environment setup has completed, refer to \l {Running JavaScript at Startup}. +\o The value of \c this is currently undefined in QML + +The value of \c this is undefined in QML. To refer to any element, provide +an \c id. For example: + +\qml +Item { + width: 200; height: 100 + function mouseAreaClicked(area) { + console.log("Clicked in area at: " + area.x + ", " + area.y); + } + // This will not work because this is undefined + MouseArea { + height: 50; width: 200 + onClicked: mouseAreaClicked(this) + } + // This will pass area2 to the function + MouseArea { + id: area2 + y: 50; height: 50; width: 200 + onClicked: mouseAreaClicked(area2) + } +} +\endqml + \endlist */ -- cgit v0.12 From 9ea7bb34e4b41e1263acb8a175f61566046f9bf6 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Tue, 27 Jul 2010 09:59:59 +1000 Subject: various doc fixes --- doc/src/declarative/dynamicobjects.qdoc | 2 +- .../tutorials/extending/chapter6-plugins/chartsplugin.cpp | 2 +- .../tutorials/extending/chapter6-plugins/chartsplugin.h | 2 +- src/declarative/qml/qdeclarativecomponent.cpp | 4 +++- src/declarative/qml/qdeclarativeengine.cpp | 2 +- src/declarative/qml/qdeclarativeimageprovider.cpp | 3 --- src/declarative/util/qdeclarativetimer.cpp | 11 +++++------ src/declarative/util/qdeclarativetransition.cpp | 4 ++-- 8 files changed, 14 insertions(+), 16 deletions(-) diff --git a/doc/src/declarative/dynamicobjects.qdoc b/doc/src/declarative/dynamicobjects.qdoc index 6bce4fa..300799c 100644 --- a/doc/src/declarative/dynamicobjects.qdoc +++ b/doc/src/declarative/dynamicobjects.qdoc @@ -148,7 +148,7 @@ lots of dynamically created items, however, you may receive a worthwhile performance benefit if unused items are deleted. Note that you should never manually delete items that were dynamically created -by QML elements (such as \l Loader). Also, you should generally avoid deleting +by QML elements (such as \l Loader and \l Repeater). Also, you should generally avoid deleting items that you did not dynamically create yourself. Items can be deleted using the \c destroy() method. This method has an optional diff --git a/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.cpp b/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.cpp index 5aa2a4b..c4d8b61 100644 --- a/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.cpp +++ b/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.cpp @@ -41,7 +41,7 @@ //![0] #include "piechart.h" #include "pieslice.h" -#include +#include void ChartsPlugin::registerTypes(const char *uri) { diff --git a/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.h b/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.h index 797d1e7..c055e8b 100644 --- a/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.h +++ b/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.h @@ -41,7 +41,7 @@ #define CHARTSPLUGIN_H //![0] -#include +#include class ChartsPlugin : public QDeclarativeExtensionPlugin { diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp index 36c4b49..7bc6184 100644 --- a/src/declarative/qml/qdeclarativecomponent.cpp +++ b/src/declarative/qml/qdeclarativecomponent.cpp @@ -119,6 +119,8 @@ class QByteArray; \qml Item { + width: 100; height: 100 + Component { id: redSquare @@ -146,7 +148,7 @@ class QByteArray; to specify how each list item is to be displayed. Component objects can also be dynamically generated using - \l{Qt::createComponent}{Qt.createComponent()}. + \l{Qt::createComponent()}{Qt.createComponent()}. */ /*! diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index e3ebca3..e313c97 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -228,7 +228,7 @@ There are also string based constructors for these types. See \l{qdeclarativebas \section1 Date/Time Formatters -The Qt object contains several functions for formatting dates and times. +The Qt object contains several functions for formatting QDateTime, QDate and QTime values. \list \o \l{QML:Qt::formatDateTime}{string Qt.formatDateTime(datetime date, variant format)} diff --git a/src/declarative/qml/qdeclarativeimageprovider.cpp b/src/declarative/qml/qdeclarativeimageprovider.cpp index a294c38..241df87 100644 --- a/src/declarative/qml/qdeclarativeimageprovider.cpp +++ b/src/declarative/qml/qdeclarativeimageprovider.cpp @@ -212,9 +212,6 @@ QImage QDeclarativeImageProvider::requestImage(const QString &id, QSize *size, c In all cases, \a size must be set to the original size of the image. This is used to set the \l {Item::}{width} and \l {Item::}{height} of image elements that should be automatically sized to the loaded image. - - \note this method may be called by multiple threads, so ensure the - implementation of this method is reentrant. */ QPixmap QDeclarativeImageProvider::requestPixmap(const QString &id, QSize *size, const QSize& requestedSize) { diff --git a/src/declarative/util/qdeclarativetimer.cpp b/src/declarative/util/qdeclarativetimer.cpp index 576995f..838a8f3 100644 --- a/src/declarative/util/qdeclarativetimer.cpp +++ b/src/declarative/util/qdeclarativetimer.cpp @@ -73,11 +73,12 @@ public: \since 4.7 \brief The Timer item triggers a handler at a specified interval. - A timer can be used to trigger an action either once, or repeatedly + A Timer can be used to trigger an action either once, or repeatedly at a given interval. - Here is a timer that shows the current date and time, and updates - the text every 500 milliseconds: + Here is a Timer that shows the current date and time, and updates + the text every 500 milliseconds. It uses the JavaScript \c Date + object to access the current time. \qml import Qt 4.7 @@ -88,9 +89,7 @@ public: onTriggered: time.text = Date().toString() } - Text { - id: time - } + Text { id: time } } \endqml diff --git a/src/declarative/util/qdeclarativetransition.cpp b/src/declarative/util/qdeclarativetransition.cpp index 6561b8c..582191b 100644 --- a/src/declarative/util/qdeclarativetransition.cpp +++ b/src/declarative/util/qdeclarativetransition.cpp @@ -66,13 +66,13 @@ QT_BEGIN_NAMESPACE \snippet doc/src/snippets/declarative/transition.qml 0 - To specify multiple transitions, specify \l Item::transitions as a list: + To define multiple transitions, specify \l Item::transitions as a list: \qml Item { ... transitions: [ - Transition { ... } + Transition { ... }, Transition { ... } ] } -- cgit v0.12 From 6c7ed006b0a1f006e11fd5f78dd996d65114fc98 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Tue, 27 Jul 2010 11:09:14 +1000 Subject: Document that animations have to be started/stopped as a group --- src/declarative/util/qdeclarativeanimation.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp index 1a223d5..9806957 100644 --- a/src/declarative/util/qdeclarativeanimation.cpp +++ b/src/declarative/util/qdeclarativeanimation.cpp @@ -1557,6 +1557,10 @@ QDeclarativeListProperty QDeclarativeAnimationGro sources. The \l PropertyAnimation documentation shows a variety of methods for creating animations. + \note Once an animation has been grouped into a SequentialAnimation or + ParallelAnimation, it cannot be individually started and stopped; the + SequentialAnimation or ParallelAnimation must be started and stopped as a group. + \sa ParallelAnimation, {QML Animation}, {declarative/animation/basics}{Animation basics example} */ @@ -1622,6 +1626,10 @@ void QDeclarativeSequentialAnimation::transition(QDeclarativeStateActions &actio sources. The \l PropertyAnimation documentation shows a variety of methods for creating animations. + \note Once an animation has been grouped into a SequentialAnimation or + ParallelAnimation, it cannot be individually started and stopped; the + SequentialAnimation or ParallelAnimation must be started and stopped as a group. + \sa SequentialAnimation, {QML Animation}, {declarative/animation/basics}{Animation basics example} */ /*! -- cgit v0.12