From 5584feca163e91588f08b0aa1f3ae2817cd90823 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 7 Oct 2009 09:53:01 +1000 Subject: Auto tests for QmlTimer --- src/declarative/fx/qfxvisualitemmodel.cpp | 38 +++--- src/declarative/util/qmltimer.cpp | 16 ++- tests/auto/declarative/declarative.pro | 5 +- tests/auto/declarative/qmltimer/qmltimer.pro | 5 + tests/auto/declarative/qmltimer/tst_qmltimer.cpp | 141 +++++++++++++++++++++++ 5 files changed, 182 insertions(+), 23 deletions(-) create mode 100644 tests/auto/declarative/qmltimer/qmltimer.pro create mode 100644 tests/auto/declarative/qmltimer/tst_qmltimer.cpp diff --git a/src/declarative/fx/qfxvisualitemmodel.cpp b/src/declarative/fx/qfxvisualitemmodel.cpp index fb1cfcf..b7248ea 100644 --- a/src/declarative/fx/qfxvisualitemmodel.cpp +++ b/src/declarative/fx/qfxvisualitemmodel.cpp @@ -264,10 +264,10 @@ public: } if (m_roles.count() == 1) m_roleNames.insert(QLatin1String("modelData"), m_roles.at(0)); - } else if (m_modelList) { + } else if (m_listAccessor) { m_roleNames.insert(QLatin1String("modelData"), 0); - if (m_modelList->type() == QmlListAccessor::Instance) { - if (QObject *object = m_modelList->at(0).value()) { + if (m_listAccessor->type() == QmlListAccessor::Instance) { + if (QObject *object = m_listAccessor->at(0).value()) { int count = object->metaObject()->propertyCount(); for (int ii = 1; ii < count; ++ii) { const QMetaProperty &prop = object->metaObject()->property(ii); @@ -330,7 +330,7 @@ public: QFxVisualDataModelData *data(QObject *item); QVariant m_modelVariant; - QmlListAccessor *m_modelList; + QmlListAccessor *m_listAccessor; int modelCount() const { if (m_visualItemModel) @@ -339,8 +339,8 @@ public: return m_listModelInterface->count(); if (m_abstractItemModel) return m_abstractItemModel->rowCount(); - if (m_modelList) - return m_modelList->count(); + if (m_listAccessor) + return m_listAccessor->count(); return 0; } }; @@ -405,7 +405,7 @@ int QFxVisualDataModelDataMetaObject::createProperty(const char *name, const cha static_cast(object()); if ((!data->m_model->m_listModelInterface || !data->m_model->m_abstractItemModel) - && data->m_model->m_modelList) { + && data->m_model->m_listAccessor) { data->m_model->ensureRoles(); if (data->m_model->m_roleNames.contains(QLatin1String(name))) return QmlOpenMetaObject::createProperty(name, type); @@ -427,16 +427,16 @@ QFxVisualDataModelDataMetaObject::propertyCreated(int, QMetaPropertyBuilder &pro static_cast(object()); QString name = QLatin1String(prop.name()); if ((!data->m_model->m_listModelInterface || !data->m_model->m_abstractItemModel) - && data->m_model->m_modelList) { + && data->m_model->m_listAccessor) { if (name == QLatin1String("modelData")) { - if (data->m_model->m_modelList->type() == QmlListAccessor::Instance) { - QObject *object = data->m_model->m_modelList->at(0).value(); + if (data->m_model->m_listAccessor->type() == QmlListAccessor::Instance) { + QObject *object = data->m_model->m_listAccessor->at(0).value(); return object->metaObject()->property(1).read(object); // the first property after objectName } - return data->m_model->m_modelList->at(data->m_index); + return data->m_model->m_listAccessor->at(data->m_index); } else { // return any property of a single object instance. - QObject *object = data->m_model->m_modelList->at(0).value(); + QObject *object = data->m_model->m_listAccessor->at(0).value(); return object->property(prop.name()); } } else if (data->m_model->m_listModelInterface) { @@ -531,7 +531,7 @@ QFxVisualDataModelParts::QFxVisualDataModelParts(QFxVisualDataModel *parent) QFxVisualDataModelPrivate::QFxVisualDataModelPrivate(QmlContext *ctxt) : m_listModelInterface(0), m_abstractItemModel(0), m_visualItemModel(0), m_delegate(0) -, m_context(ctxt), m_parts(0), m_modelList(0) +, m_context(ctxt), m_parts(0), m_listAccessor(0) { } @@ -556,8 +556,8 @@ QFxVisualDataModel::QFxVisualDataModel(QmlContext *ctxt) QFxVisualDataModel::~QFxVisualDataModel() { Q_D(QFxVisualDataModel); - if (d->m_modelList) - delete d->m_modelList; + if (d->m_listAccessor) + delete d->m_listAccessor; } QVariant QFxVisualDataModel::model() const @@ -569,8 +569,8 @@ QVariant QFxVisualDataModel::model() const void QFxVisualDataModel::setModel(const QVariant &model) { Q_D(QFxVisualDataModel); - delete d->m_modelList; - d->m_modelList = 0; + delete d->m_listAccessor; + d->m_listAccessor = 0; d->m_modelVariant = model; if (d->m_listModelInterface) { // Assume caller has released all items. @@ -642,8 +642,8 @@ void QFxVisualDataModel::setModel(const QVariant &model) this, SLOT(_q_destroyingPackage(QmlPackage*))); return; } - d->m_modelList = new QmlListAccessor; - d->m_modelList->setList(model, d->m_context?d->m_context->engine():qmlEngine(this)); + d->m_listAccessor = new QmlListAccessor; + d->m_listAccessor->setList(model, d->m_context?d->m_context->engine():qmlEngine(this)); if (d->m_delegate && d->modelCount()) { emit itemsInserted(0, d->modelCount()); emit countChanged(); diff --git a/src/declarative/util/qmltimer.cpp b/src/declarative/util/qmltimer.cpp index b95d6ad..fdc57ff 100644 --- a/src/declarative/util/qmltimer.cpp +++ b/src/declarative/util/qmltimer.cpp @@ -100,6 +100,8 @@ QmlTimer::QmlTimer(QObject *parent) \qmlproperty int Timer::interval Sets the \a interval in milliseconds between triggering. + + The default interval is 1000 milliseconds. */ void QmlTimer::setInterval(int interval) { @@ -123,6 +125,8 @@ int QmlTimer::interval() const For a non-repeating timer, \a running will be set to false after the timer has been triggered. + \a running defaults to false. + \sa repeat */ bool QmlTimer::isRunning() const @@ -148,6 +152,8 @@ void QmlTimer::setRunning(bool running) specified interval; otherwise, the timer will trigger once at the specified interval and then stop (i.e. running will be set to false). + \a repeat defaults to false. + \sa running */ bool QmlTimer::isRepeating() const @@ -169,7 +175,11 @@ void QmlTimer::setRepeating(bool repeating) \qmlproperty bool Timer::triggeredOnStart If \a triggeredOnStart is true, the timer will be triggered immediately - when started, and subsequently at the specified interval. + when started, and subsequently at the specified interval. Note that for + a Timer with \e repeat set to false, this will result in the timer being + triggered twice; once on start, and again at the interval. + + \a triggeredOnStart defaults to false. \sa running */ @@ -198,7 +208,7 @@ void QmlTimer::setTriggeredOnStart(bool triggeredOnStart) void QmlTimer::start() { Q_D(QmlTimer); - d->pause.start(); + setRunning(true); } /*! @@ -211,7 +221,7 @@ void QmlTimer::start() void QmlTimer::stop() { Q_D(QmlTimer); - d->pause.stop(); + setRunning(false); } void QmlTimer::update() diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro index 4724278..f2ddbb7 100644 --- a/tests/auto/declarative/declarative.pro +++ b/tests/auto/declarative/declarative.pro @@ -7,13 +7,16 @@ SUBDIRS += datetimeformatter \ pathview \ qfxtext \ qfxtextedit \ - simplecanvasitem \ repeater \ qmllanguage \ qmlecmascript \ qmlmetaproperty \ qmllist \ qmllistaccessor \ + qmltimer \ + qfxloader \ + qfxwebview \ + states \ visual # Tests which should run in Pulse diff --git a/tests/auto/declarative/qmltimer/qmltimer.pro b/tests/auto/declarative/qmltimer/qmltimer.pro new file mode 100644 index 0000000..e7edd96 --- /dev/null +++ b/tests/auto/declarative/qmltimer/qmltimer.pro @@ -0,0 +1,5 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative gui +SOURCES += tst_qmltimer.cpp + +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qmltimer/tst_qmltimer.cpp b/tests/auto/declarative/qmltimer/tst_qmltimer.cpp new file mode 100644 index 0000000..15b558f --- /dev/null +++ b/tests/auto/declarative/qmltimer/tst_qmltimer.cpp @@ -0,0 +1,141 @@ +#include +#include +#include +#include + +class tst_qmltimer : public QObject +{ + Q_OBJECT +public: + tst_qmltimer(); + +private slots: + void notRepeating(); + void notRepeatingStart(); + void repeat(); + void triggeredOnStart(); + void triggeredOnStartRepeat(); +}; + +class TimerHelper : public QObject +{ + Q_OBJECT +public: + TimerHelper() : QObject(), count(0) + { + } + + int count; + +public slots: + void timeout() { + ++count; + } +}; + +#if defined(Q_OS_SYMBIAN) && defined(Q_CC_NOKIAX86) +// Increase wait as emulator startup can cause unexpected delays +#define TIMEOUT_TIMEOUT 2000 +#else +#define TIMEOUT_TIMEOUT 200 +#endif + +tst_qmltimer::tst_qmltimer() +{ +} + +void tst_qmltimer::notRepeating() +{ + QmlEngine engine; + QmlComponent component(&engine, QByteArray("import Qt 4.6\nTimer { interval: 100; running: true }"), QUrl("file://")); + QmlTimer *timer = qobject_cast(component.create()); + QVERIFY(timer != 0); + + TimerHelper helper; + connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); + + QTest::qWait(TIMEOUT_TIMEOUT); + QCOMPARE(helper.count, 1); + QTest::qWait(TIMEOUT_TIMEOUT); + QCOMPARE(helper.count, 1); +} + +void tst_qmltimer::notRepeatingStart() +{ + QmlEngine engine; + QmlComponent component(&engine, QByteArray("import Qt 4.6\nTimer { interval: 100 }"), QUrl("file://")); + QmlTimer *timer = qobject_cast(component.create()); + QVERIFY(timer != 0); + + TimerHelper helper; + connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); + + QTest::qWait(TIMEOUT_TIMEOUT); + QCOMPARE(helper.count, 0); + + timer->start(); + QTest::qWait(TIMEOUT_TIMEOUT); + QCOMPARE(helper.count, 1); + QTest::qWait(TIMEOUT_TIMEOUT); + QCOMPARE(helper.count, 1); +} + +void tst_qmltimer::repeat() +{ + QmlEngine engine; + QmlComponent component(&engine, QByteArray("import Qt 4.6\nTimer { interval: 100; repeat: true; running: true }"), QUrl("file://")); + QmlTimer *timer = qobject_cast(component.create()); + QVERIFY(timer != 0); + + TimerHelper helper; + connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); + QCOMPARE(helper.count, 0); + + QTest::qWait(TIMEOUT_TIMEOUT); + QVERIFY(helper.count > 0); + int oldCount = helper.count; + + QTest::qWait(TIMEOUT_TIMEOUT); + QVERIFY(helper.count > oldCount); +} + +void tst_qmltimer::triggeredOnStart() +{ + QmlEngine engine; + QmlComponent component(&engine, QByteArray("import Qt 4.6\nTimer { interval: 100; running: true; triggeredOnStart: true }"), QUrl("file://")); + QmlTimer *timer = qobject_cast(component.create()); + QVERIFY(timer != 0); + + TimerHelper helper; + connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); + QTest::qWait(1); + QCOMPARE(helper.count, 1); + + QTest::qWait(TIMEOUT_TIMEOUT); + QCOMPARE(helper.count, 2); + QTest::qWait(TIMEOUT_TIMEOUT); + QCOMPARE(helper.count, 2); +} + +void tst_qmltimer::triggeredOnStartRepeat() +{ + QmlEngine engine; + QmlComponent component(&engine, QByteArray("import Qt 4.6\nTimer { interval: 100; running: true; triggeredOnStart: true; repeat: true }"), QUrl("file://")); + QmlTimer *timer = qobject_cast(component.create()); + QVERIFY(timer != 0); + + TimerHelper helper; + connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); + QTest::qWait(1); + QCOMPARE(helper.count, 1); + + QTest::qWait(TIMEOUT_TIMEOUT); + QVERIFY(helper.count > 1); + int oldCount = helper.count; + QTest::qWait(TIMEOUT_TIMEOUT); + QVERIFY(helper.count > oldCount); +} + +QTEST_MAIN(tst_qmltimer) + +#include "tst_qmltimer.moc" -- cgit v0.12 From 0e91a2e5cb940f5f677345a2f811061b75b32635 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 7 Oct 2009 07:29:06 +0200 Subject: Compile on Symbian. --- src/declarative/util/qmllistmodel.cpp | 80 +++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 36 deletions(-) diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp index 69bed25..062ab48 100644 --- a/src/declarative/util/qmllistmodel.cpp +++ b/src/declarative/util/qmllistmodel.cpp @@ -239,41 +239,8 @@ struct ModelNode return objectCache; } - void setListValue(const QScriptValue& valuelist) { - QScriptValueIterator it(valuelist); - values.clear(); - while (it.hasNext()) { - it.next(); - ModelNode *value = new ModelNode; - QScriptValue v = it.value(); - if (v.isArray()) { - value->setListValue(v); - } else if (v.isObject()) { - value->setObjectValue(v); - } else { - value->values << v.toVariant(); - } - values.append(qVariantFromValue(value)); - - } - } - - void setObjectValue(const QScriptValue& valuemap) { - QScriptValueIterator it(valuemap); - while (it.hasNext()) { - it.next(); - ModelNode *value = new ModelNode; - QScriptValue v = it.value(); - if (v.isArray()) { - value->setListValue(v); - } else if (v.isObject()) { - value->setObjectValue(v); - } else { - value->values << v.toVariant(); - } - properties.insert(it.name(),value); - } - } + void setObjectValue(const QScriptValue& valuemap); + void setListValue(const QScriptValue& valuelist); void setProperty(const QString& prop, const QVariant& val) { QHash::const_iterator it = properties.find(prop); @@ -292,6 +259,48 @@ struct ModelNode ModelObject *objectCache; }; +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(ModelNode *) + +QT_BEGIN_NAMESPACE +void ModelNode::setObjectValue(const QScriptValue& valuemap) { + QScriptValueIterator it(valuemap); + while (it.hasNext()) { + it.next(); + ModelNode *value = new ModelNode; + QScriptValue v = it.value(); + if (v.isArray()) { + value->setListValue(v); + } else if (v.isObject()) { + value->setObjectValue(v); + } else { + value->values << v.toVariant(); + } + properties.insert(it.name(),value); + } +} + +void ModelNode::setListValue(const QScriptValue& valuelist) { + QScriptValueIterator it(valuelist); + values.clear(); + while (it.hasNext()) { + it.next(); + ModelNode *value = new ModelNode; + QScriptValue v = it.value(); + if (v.isArray()) { + value->setListValue(v); + } else if (v.isObject()) { + value->setObjectValue(v); + } else { + value->values << v.toVariant(); + } + values.append(qVariantFromValue(value)); + + } +} + + ModelObject::ModelObject() : _mo(new QmlOpenMetaObject(this)) { @@ -846,7 +855,6 @@ ModelNode::~ModelNode() QT_END_NAMESPACE -Q_DECLARE_METATYPE(ModelNode *) QML_DECLARE_TYPE(QmlListElement) #include "qmllistmodel.moc" -- cgit v0.12 From 833ca7b4f038b92e1bdbc6368ec73c9eb4568f7c Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Wed, 7 Oct 2009 15:36:56 +1000 Subject: Update 'hello world' tutorial. --- doc/src/declarative/qmlintro.qdoc | 2 +- doc/src/declarative/qmlreference.qdoc | 2 +- doc/src/declarative/tutorial.qdoc | 12 +- doc/src/declarative/tutorial1.qdoc | 62 +++------- doc/src/declarative/tutorial2.qdoc | 135 ++++++--------------- doc/src/declarative/tutorial3.qdoc | 124 +++++-------------- doc/src/images/declarative-tutorial1.png | Bin 3025 -> 3577 bytes doc/src/images/declarative-tutorial2.png | Bin 3050 -> 3913 bytes doc/src/images/declarative-tutorial3_animation.gif | Bin 38111 -> 301974 bytes .../tutorials/helloworld/t1/tutorial1.qml | 20 +-- .../declarative/tutorials/helloworld/t2/Cell.qml | 26 +++- .../tutorials/helloworld/t2/tutorial2.qml | 34 +++--- .../declarative/tutorials/helloworld/t3/Cell.qml | 15 ++- .../tutorials/helloworld/t3/tutorial3.qml | 79 ++++++------ 14 files changed, 192 insertions(+), 319 deletions(-) diff --git a/doc/src/declarative/qmlintro.qdoc b/doc/src/declarative/qmlintro.qdoc index e87b7a8..ef84b8e 100644 --- a/doc/src/declarative/qmlintro.qdoc +++ b/doc/src/declarative/qmlintro.qdoc @@ -153,7 +153,7 @@ Item { } \endcode -\section3 The 'id' property +\section3 The \c id property The \c id property is a special property of type \e id. Assigning an id to an object allows you to refer to it elsewhere. diff --git a/doc/src/declarative/qmlreference.qdoc b/doc/src/declarative/qmlreference.qdoc index bb0d61a..b26fc64 100644 --- a/doc/src/declarative/qmlreference.qdoc +++ b/doc/src/declarative/qmlreference.qdoc @@ -18,7 +18,7 @@ Getting Started: \list \o \l {Introduction to the QML language} (in progress) - \o \l {tutorial}{Tutorial: 'Hello World'} + \o \l {tutorial}{Tutorial: 'Hello world!'} \o \l {tutorials-declarative-contacts.html}{Tutorial: 'Introduction to QML'} \o \l {qmlexamples}{Examples} \endlist diff --git a/doc/src/declarative/tutorial.qdoc b/doc/src/declarative/tutorial.qdoc index a2a34b9..b59384c 100644 --- a/doc/src/declarative/tutorial.qdoc +++ b/doc/src/declarative/tutorial.qdoc @@ -2,7 +2,11 @@ \page tutorial.html \title Tutorial -This tutorial gives an introduction to QML. It doesn't cover everything; the emphasis is on teaching the key principles, and features are introduced as needed. +This tutorial gives an introduction to QML. It doesn't cover everything; the emphasis is on teaching the key principles, +and features are introduced as needed. + +Through the different steps of this tutorial we will learn about QML basic types, we will create our own QML component +with properties and signals, and we will create a simple animation with the help of states and transitions. Chapter one starts with a minimal "Hello world" program and the following chapters introduce new concepts. @@ -11,9 +15,9 @@ The tutorial's source code is located in the $QTDIR/examples/declarative/tutoria Tutorial chapters: \list -\o \l {tutorial1}{Tutorial 1} -\o \l {tutorial2}{Tutorial 2} -\o \l {tutorial3}{Tutorial 3} +\o \l {tutorial1}{Tutorial 1 - Basic Types} +\o \l {tutorial2}{Tutorial 2 - QML Component} +\o \l {tutorial3}{Tutorial 3 - States and Transitions} \endlist */ diff --git a/doc/src/declarative/tutorial1.qdoc b/doc/src/declarative/tutorial1.qdoc index d4f1095..f46c59d 100644 --- a/doc/src/declarative/tutorial1.qdoc +++ b/doc/src/declarative/tutorial1.qdoc @@ -1,68 +1,46 @@ /*! \page tutorial1.html -\title Tutorial 1 - Hello World! +\title Tutorial 1 - Basic Types \target tutorial1 -This first program is a simple "Hello world" example. The picture below is a screenshot of this program. +This first program is a very simple "Hello world" example that introduces some basic QML concepts. +The picture below is a screenshot of this program. \image declarative-tutorial1.png Here is the QML code for the application: -\code -Rectangle { - id: Page - width: 480 - height: 200 - color: "LightGrey" - Text { - id: HelloText - text: "Hello world!" - font.pointSize: 24 - font.bold: true - y: 30 - anchors.horizontalCenter: Page.horizontalCenter - } -} -\endcode +\snippet examples/declarative/tutorials/helloworld/t1/tutorial1.qml 0 \section1 Walkthrough +\section2 Import + +First, we need to import the types that we need for this example. Most QML files will import the built-in QML +types (like \l{Rectangle}, \l{Image}, ...) that come with Qt with: + +\snippet examples/declarative/tutorials/helloworld/t1/tutorial1.qml 3 + \section2 Rectangle element -\code -Rectangle { - id: Page - width: 480 - height: 200 - color: "LightGrey" -} -\endcode +\snippet examples/declarative/tutorials/helloworld/t1/tutorial1.qml 1 -First, we declare a root element of type \l Rectangle. It is one of the basic building blocks you can use to create an application in QML. -We give it an id to be able to refer to it later. In this case, we call it \e Page. We also set the \c width, \c height and \c color properties. -The \l Rectangle element contains many other properties (such as \c x and \c y), but these are left at their default values. +We declare a root element of type \l{Rectangle}. It is one of the basic building blocks you can use to create an application in QML. +We give it an \c{id} to be able to refer to it later. In this case, we call it \e page. We also set the \c width, \c height and \c color properties. +The \l{Rectangle} element contains many other properties (such as \c x and \c y), but these are left at their default values. \section2 Text element -\code -Text { - id: HelloText - text: "Hello world!" - font.pointSize: 24 - font.bold: true - y: 30 - anchors.horizontalCenter: Page.horizontalCenter -} -\endcode +\snippet examples/declarative/tutorials/helloworld/t1/tutorial1.qml 2 -We add a text element as a child of our root element to display the text 'Hello world!'. +We add a \l Text element as a child of our root element that will display the text 'Hello world!'. The \c y property is used to position the text vertically at 30 pixels from the top of its parent. -The \c font.pointSize and \c font.bold properties are related to fonts and use the \e 'dot' notation. +The \c font.pointSize and \c font.bold properties are related to fonts and use the \l{Dot Properties}{dot notation}. -The \c anchors.horizontalCenter property refers to the horizontal center of an element. In this case, we specify that our text element should be horizontally centered in the \e Page element. +The \c anchors.horizontalCenter property refers to the horizontal center of an element. +In this case, we specify that our text element should be horizontally centered in the \e page element (see \l{anchor-layout}{Anchor-based Layout}). \section2 Viewing the example diff --git a/doc/src/declarative/tutorial2.qdoc b/doc/src/declarative/tutorial2.qdoc index c6fd06b..21b5ebd 100644 --- a/doc/src/declarative/tutorial2.qdoc +++ b/doc/src/declarative/tutorial2.qdoc @@ -1,130 +1,69 @@ /*! \page tutorial2.html -\title Tutorial 2 - Some colors +\title Tutorial 2 - QML Component \target tutorial2 This chapter adds a color picker to change the color of the text. \image declarative-tutorial2.png -Our color picker is made of many cells with different colors. To avoid writing the same code many times, we first create a new \c Cell component with a color property (see \l components). +Our color picker is made of six cells with different colors. +To avoid writing the same code multiple times, we first create a new \c Cell component. +A component provides a way of defining a new type that we can re-use in other QML files. +A QML component is like a black-box and interacts with the outside world through properties, signals and slots and is generally +defined in its own QML file (for more details, see \l components). Here is the QML code for \c Cell.qml: -\code -Item { - property var color - - id: CellContainer - width: 40 - height: 25 - - Rectangle { - anchors.fill: parent - color: CellContainer.color - } - MouseRegion { - anchors.fill: parent - onClicked: { HelloText.color = CellContainer.color } - } -} -\endcode - -Then, we use our \c Cell component to create the color picker in the QML code for the application: - -\code -Rectangle { - id: Page - width: 480 - height: 200 - color: "LightGrey" - Text { - id: HelloText - text: "Hello world!" - font.pointSize: 24 - font.bold: true - y: 30 - anchors.horizontalCenter: Page.horizontalCenter - } - Grid { - id: ColorPicker - x: 0 - anchors.bottom: Page.bottom - width: 120; height: 50 - rows: 2; columns: 3 - Cell { color: "#ff0000" } - Cell { color: "#00ff00" } - Cell { color: "#0000ff" } - Cell { color: "#ffff00" } - Cell { color: "#00ffff" } - Cell { color: "#ff00ff" } - } -} -\endcode +\snippet examples/declarative/tutorials/helloworld/t2/Cell.qml 0 \section1 Walkthrough \section2 The Cell Component -\code -Item { - id: CellContainer - width: 40 - height: 25 -} -\endcode +\snippet examples/declarative/tutorials/helloworld/t2/Cell.qml 1 -The root element of our component is an \c Item. It is the most basic element in QML and is often used as a container for other elements. +The root element of our component is an \l Item with the \c id \e container. +An \l Item is the most basic visual element in QML and is often used as a container for other elements. -\code -property var color -\endcode +\snippet examples/declarative/tutorials/helloworld/t2/Cell.qml 4 -We declare a \c color property. This property is accessible from \e outside our component, this allows us to instantiate the cells with different colors. +We declare a \c color property. This property is accessible from \e outside our component, this allows us +to instantiate the cells with different colors. +This property is just an alias to an existing property - the color of the rectangle that compose the cell (see \l{Properties}). -\code -Rectangle { - anchors.fill: parent - color: CellContainer.color -} -\endcode +\snippet examples/declarative/tutorials/helloworld/t2/Cell.qml 5 -Our cell component is basically a colored rectangle. +We want our component to also have a signal that we call \e clicked with a \e color parameter. +We will use this signal to change the color of the text in the main QML file later. -The \c anchors.fill property is a convenient way to set the size of an element. In this case the \c Rectangle will have the same size as its parent. +\snippet examples/declarative/tutorials/helloworld/t2/Cell.qml 2 -We bind the \c color property of this \c Rectangle to the color property of our component. +Our cell component is basically a colored rectangle with the \c id \e rectangle. -\code -MouseRegion { - anchors.fill: parent - onClicked: { HelloText.color = CellContainer.color } -} -\endcode +The \c anchors.fill property is a convenient way to set the size of an element. +In this case the rectangle will have the same size as its parent (see \l{anchor-layout}{Anchor-based Layout}). -In order to change the color of the text when clicking on a cell, we create a \c MouseRegion element with the same size as its parent. +\snippet examples/declarative/tutorials/helloworld/t2/Cell.qml 3 -The \c onClicked property sets the \c color property of the element named \e HelloText to our cell color. +In order to change the color of the text when clicking on a cell, we create a \l MouseRegion element with +the same size as its parent. + +A \l MouseRegion defines a signal called \e clicked. +When this signal is triggered we want to emit our own \e clicked signal with the color as parameter. \section2 The main QML file -\code -Grid { - id: ColorPicker - x: 0 - anchors.bottom: Page.bottom - width: 120; height: 50 - rows: 2; columns: 3 - Cell { color: "#ff0000" } - Cell { color: "#00ff00" } - Cell { color: "#0000ff" } - Cell { color: "#ffff00" } - Cell { color: "#00ffff" } - Cell { color: "#ff00ff" } -} -\endcode - -In the main QML file, the only thing we have to do is to create a color picker by putting 6 cells with different colors in a grid. +In our main QML file, we use our \c Cell component to create the color picker: + +\snippet examples/declarative/tutorials/helloworld/t2/tutorial2.qml 0 + +We create the color picker by putting 6 cells with different colors in a grid. + +\snippet examples/declarative/tutorials/helloworld/t2/tutorial2.qml 1 + +When the \e clicked signal of our cell is triggered, we want to set the color of the text to the color passed as a parameter. +We can react to any signal of our component through a property of the name \e 'onSignalName' (see \l{Signal Handlers}). [Previous: \l tutorial1] [Next: \l tutorial3] diff --git a/doc/src/declarative/tutorial3.qdoc b/doc/src/declarative/tutorial3.qdoc index a0d842c..21b7ae5 100644 --- a/doc/src/declarative/tutorial3.qdoc +++ b/doc/src/declarative/tutorial3.qdoc @@ -1,111 +1,43 @@ -/*! +/*! \page tutorial3.html -\title Tutorial 3 - States +\title Tutorial 3 - States and Transitions \target tutorial3 -In this chapter, we make this example a little bit more dynamic by introducing states. +In this chapter, we make this example a little bit more dynamic by introducing states and transitions. -We want our text to jump at the bottom of the screen and become red when clicked. +We want our text to move to the bottom of the screen, rotate and become red when clicked. \image declarative-tutorial3_animation.gif Here is the QML code: -\code -Rectangle { - id: Page - width: 480 - height: 200 - color: "LightGrey" - Text { - id: HelloText - text: "Hello world!" - font.pointSize: 24 - font.bold: true - y: 30 - anchors.horizontalCenter: Page.horizontalCenter - states: [ - State { - name: "down" - when: MouseRegion.pressed == true - PropertyChanges { target: HelloText; y: 160; color: "red" } - } - ] - transitions: [ - Transition { - from: "*" - to: "down" - reversible: true - ParallelAnimation { - NumberAnimation { - properties: "y" - duration: 500 - easing: "easeOutBounce" - } - ColorAnimation { property: "color"; duration: 500 } - } - } - ] - } - MouseRegion { id: MouseRegion; anchors.fill: HelloText } - Grid { - id: ColorPicker - x: 0 - anchors.bottom: Page.bottom - width: 120; height: 50 - rows: 2; columns: 3 - Cell { color: "#ff0000" } - Cell { color: "#00ff00" } - Cell { color: "#0000ff" } - Cell { color: "#ffff00" } - Cell { color: "#00ffff" } - Cell { color: "#ff00ff" } - } -} -\endcode +\snippet examples/declarative/tutorials/helloworld/t3/tutorial3.qml 0 \section1 Walkthrough -\code -states: [ - State { - name: "down" - when: MouseRegion.pressed == true - PropertyChanges { target: HelloText; y: 160; color: "red" } - } -] -\endcode - -First, we create a new state \e down for our text element. This state will be activated when MouseRegion is pressed, and deactivated when it is released. - -The \e down state includes a set of property changes from our implicit \e {default state} (the items as they were initially defined in the QML). Specifically, we set the \c y property of the text to 160 and the \c color to red. - -\code -Transition { - from: "*" - to: "down" - reversible: true -} -\endcode - -Because we don't want the text to appear at the bottom instantly but rather move smoothly, we add a transition between our two states. - -\c from and \c to define the states between which the transition will run. In this case, we want a transition from any state to our \e down state. - -Because we want the same transition to be run in reverse when changing back from the \e down state to the default state, we set \c reversible to \c true. This is equivalent to writing the two transitions separately. - -\code -ParallelAnimation { - NumberAnimation { - properties: "y" - duration: 500 - easing: "easeOutBounce" - } - ColorAnimation { property: "color"; duration: 500 } -} -\endcode - -The \c ParallelAnimation element makes sure that the two animations (color and position) will start at the same time. We could also run them one after the other by using \c SequentialAnimation instead. +\snippet examples/declarative/tutorials/helloworld/t3/tutorial3.qml 2 + +First, we create a new \e down state for our text element. +This state will be activated when the \l MouseRegion is pressed, and deactivated when it is released. + +The \e down state includes a set of property changes from our implicit \e {default state} +(the items as they were initially defined in the QML). +Specifically, we set the \c y property of the text to \c 160, the rotation to \c 180 and the \c color to red. + +\snippet examples/declarative/tutorials/helloworld/t3/tutorial3.qml 3 + +Because we don't want the text to appear at the bottom instantly but rather move smoothly, +we add a transition between our two states. + +\c from and \c to define the states between which the transition will run. +In this case, we want a transition from the default state to our \e down state. + +Because we want the same transition to be run in reverse when changing back from the \e down state to the default state, +we set \c reversible to \c true. +This is equivalent to writing the two transitions separately. + +The \l ParallelAnimation element makes sure that the two types of animations (number and color) start at the same time. +We could also run them one after the other by using \l SequentialAnimation instead. For more details on states and transitions, see \l {states-transitions}{States and Transitions}. diff --git a/doc/src/images/declarative-tutorial1.png b/doc/src/images/declarative-tutorial1.png index ea0000f..c9d3844 100644 Binary files a/doc/src/images/declarative-tutorial1.png and b/doc/src/images/declarative-tutorial1.png differ diff --git a/doc/src/images/declarative-tutorial2.png b/doc/src/images/declarative-tutorial2.png index 0538451..835484a 100644 Binary files a/doc/src/images/declarative-tutorial2.png and b/doc/src/images/declarative-tutorial2.png differ diff --git a/doc/src/images/declarative-tutorial3_animation.gif b/doc/src/images/declarative-tutorial3_animation.gif index d2d4c63..80b78de 100644 Binary files a/doc/src/images/declarative-tutorial3_animation.gif and b/doc/src/images/declarative-tutorial3_animation.gif differ diff --git a/examples/declarative/tutorials/helloworld/t1/tutorial1.qml b/examples/declarative/tutorials/helloworld/t1/tutorial1.qml index e2c6650..93d3c34 100644 --- a/examples/declarative/tutorials/helloworld/t1/tutorial1.qml +++ b/examples/declarative/tutorials/helloworld/t1/tutorial1.qml @@ -1,16 +1,22 @@ +//![0] +//![3] import Qt 4.6 +//![3] +//![1] Rectangle { id: page - width: 480 - height: 200 - color: "LightGrey" + width: 500; height: 200 + color: "lightgray" +//![1] + +//![2] Text { id: helloText text: "Hello world!" - font.pointSize: 24 - font.bold: true - y: 30 - anchors.horizontalCenter: page.horizontalCenter + font.pointSize: 24; font.bold: true + y: 30; anchors.horizontalCenter: page.horizontalCenter } +//![2] } +//![0] diff --git a/examples/declarative/tutorials/helloworld/t2/Cell.qml b/examples/declarative/tutorials/helloworld/t2/Cell.qml index bfd835d..ab6e565 100644 --- a/examples/declarative/tutorials/helloworld/t2/Cell.qml +++ b/examples/declarative/tutorials/helloworld/t2/Cell.qml @@ -1,18 +1,32 @@ +//![0] import Qt 4.6 +//![1] Item { - property var color + id: container +//![4] + property alias color: rectangle.color +//![4] +//![5] + signal clicked(string color) +//![5] - id: cellContainer - width: 40 - height: 25 + width: 40; height: 25 +//![1] +//![2] Rectangle { + id: rectangle + border.color: "white" anchors.fill: parent - color: cellContainer.color } +//![2] + +//![3] MouseRegion { anchors.fill: parent - onClicked: { helloText.color = cellContainer.color } + onClicked: container.clicked(container.color) } +//![3] } +//![0] diff --git a/examples/declarative/tutorials/helloworld/t2/tutorial2.qml b/examples/declarative/tutorials/helloworld/t2/tutorial2.qml index aee9032..99889d7 100644 --- a/examples/declarative/tutorials/helloworld/t2/tutorial2.qml +++ b/examples/declarative/tutorials/helloworld/t2/tutorial2.qml @@ -1,29 +1,31 @@ +//![0] import Qt 4.6 Rectangle { id: page - width: 480 - height: 200 - color: "LightGrey" + width: 500; height: 200 + color: "lightgray" + Text { id: helloText text: "Hello world!" - font.pointSize: 24 - font.bold: true - y: 30 - anchors.horizontalCenter: page.horizontalCenter + font.pointSize: 24; font.bold: true + y: 30; anchors.horizontalCenter: page.horizontalCenter } + Grid { id: colorPicker - x: 0 anchors.bottom: page.bottom - width: 120; height: 50 - rows: 2; columns: 3 - Cell { color: "#ff0000" } - Cell { color: "#00ff00" } - Cell { color: "#0000ff" } - Cell { color: "#ffff00" } - Cell { color: "#00ffff" } - Cell { color: "#ff00ff" } + rows: 2; columns: 3; spacing: 3 + +//![1] + Cell { color: "red"; onClicked: helloText.color = color } +//![1] + Cell { color: "green"; onClicked: helloText.color = color } + Cell { color: "blue"; onClicked: helloText.color = color } + Cell { color: "yellow"; onClicked: helloText.color = color } + Cell { color: "steelblue"; onClicked: helloText.color = color } + Cell { color: "black"; onClicked: helloText.color = color } } } +//![0] diff --git a/examples/declarative/tutorials/helloworld/t3/Cell.qml b/examples/declarative/tutorials/helloworld/t3/Cell.qml index 6feb7a9..578369d 100644 --- a/examples/declarative/tutorials/helloworld/t3/Cell.qml +++ b/examples/declarative/tutorials/helloworld/t3/Cell.qml @@ -1,17 +1,20 @@ import Qt 4.6 Item { - property var color + id: container + property alias color: rectangle.color + signal clicked(string color) + + width: 40; height: 25 - id: cellContainer - width: 40 - height: 25 Rectangle { + id: rectangle + border.color: "white" anchors.fill: parent - color: cellContainer.color } + MouseRegion { anchors.fill: parent - onClicked: { helloText.color = cellContainer.color } + onClicked: container.clicked(container.color) } } diff --git a/examples/declarative/tutorials/helloworld/t3/tutorial3.qml b/examples/declarative/tutorials/helloworld/t3/tutorial3.qml index b80065d..d641eba 100644 --- a/examples/declarative/tutorials/helloworld/t3/tutorial3.qml +++ b/examples/declarative/tutorials/helloworld/t3/tutorial3.qml @@ -1,56 +1,51 @@ +//![0] import Qt 4.6 Rectangle { id: page - width: 480 - height: 200 - color: "LightGrey" + width: 500; height: 200 + color: "lightgray" + Text { id: helloText text: "Hello world!" - font.pointSize: 24 - font.bold: true - y: 30 - anchors.horizontalCenter: page.horizontalCenter - states: [ - State { - name: "down" - when: mouseRegion.pressed == true - PropertyChanges { - target: helloText - y: 160 - color: "red" - } - } - ] - transitions: [ - Transition { - from: "*" - to: "down" - reversible: true - ParallelAnimation { - NumberAnimation { - properties: "y" - duration: 500 - easing: "easeOutBounce" - } - ColorAnimation { property: "color"; duration: 500 } - } + font.pointSize: 24; font.bold: true + y: 30; anchors.horizontalCenter: page.horizontalCenter + transformOrigin: "Center" + +//![1] + MouseRegion { id: mouseRegion; anchors.fill: parent } +//![1] + +//![2] + states: State { + name: "down"; when: mouseRegion.pressed == true + PropertyChanges { target: helloText; y: 160; rotation: 180; color: "red" } + } +//![2] + +//![3] + transitions: Transition { + from: ""; to: "down"; reversible: true + ParallelAnimation { + NumberAnimation { properties: "y,rotation"; duration: 500; easing: "easeInOutQuad" } + ColorAnimation { property: "color"; duration: 500 } } - ] + } +//![3] } - MouseRegion { id: mouseRegion; anchors.fill: helloText } + Grid { id: colorPicker - x: 0 anchors.bottom: page.bottom - width: 120; height: 50 - rows: 2; columns: 3 - Cell { color: "#ff0000" } - Cell { color: "#00ff00" } - Cell { color: "#0000ff" } - Cell { color: "#ffff00" } - Cell { color: "#00ffff" } - Cell { color: "#ff00ff" } + rows: 2; columns: 3; spacing: 3 + + Cell { color: "red"; onClicked: helloText.color = color } + Cell { color: "green"; onClicked: helloText.color = color } + Cell { color: "blue"; onClicked: helloText.color = color } + Cell { color: "yellow"; onClicked: helloText.color = color } + Cell { color: "steelblue"; onClicked: helloText.color = color } + Cell { color: "black"; onClicked: helloText.color = color } } } +//![0] -- cgit v0.12 From d16640f186f0588935ce99a14927cdf6f2a2fa98 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 7 Oct 2009 16:38:31 +1000 Subject: Smaller gif file for the advanced tutorial --- .../declarative/pics/declarative-adv-tutorial4.gif | Bin 58337629 -> 1687445 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/doc/src/declarative/pics/declarative-adv-tutorial4.gif b/doc/src/declarative/pics/declarative-adv-tutorial4.gif index a67666d..827458d 100644 Binary files a/doc/src/declarative/pics/declarative-adv-tutorial4.gif and b/doc/src/declarative/pics/declarative-adv-tutorial4.gif differ -- cgit v0.12 From 605f47d61c44e1219811b2d68d3fcb51ab284015 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 7 Oct 2009 16:51:00 +1000 Subject: Fix QFxTextInput It was accepting input on both press and release, for some reason --- src/declarative/fx/qfxtextinput.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/declarative/fx/qfxtextinput.cpp b/src/declarative/fx/qfxtextinput.cpp index b7b155a..05d2260 100644 --- a/src/declarative/fx/qfxtextinput.cpp +++ b/src/declarative/fx/qfxtextinput.cpp @@ -594,6 +594,7 @@ bool QFxTextInput::event(QEvent* ev) bool handled = false; switch(ev->type()){ case QEvent::KeyPress: + case QEvent::KeyRelease://###Should the control be doing anything with release? case QEvent::GraphicsSceneMousePress: break; default: -- cgit v0.12 From 28e0f484cfb2b677661f0cb1a90a7b88d8f46f03 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Wed, 7 Oct 2009 17:07:55 +1000 Subject: move files to avoid duplication. --- doc/src/declarative/tutorial1.qdoc | 17 ++++---- doc/src/declarative/tutorial2.qdoc | 16 +++---- doc/src/declarative/tutorial3.qdoc | 7 ++- examples/declarative/tutorials/helloworld/Cell.qml | 32 ++++++++++++++ .../tutorials/helloworld/t1/tutorial1.qml | 22 ---------- .../declarative/tutorials/helloworld/t2/Cell.qml | 32 -------------- .../tutorials/helloworld/t2/tutorial2.qml | 31 ------------- .../declarative/tutorials/helloworld/t3/Cell.qml | 20 --------- .../tutorials/helloworld/t3/tutorial3.qml | 51 ---------------------- .../declarative/tutorials/helloworld/tutorial1.qml | 22 ++++++++++ .../declarative/tutorials/helloworld/tutorial2.qml | 31 +++++++++++++ .../declarative/tutorials/helloworld/tutorial3.qml | 51 ++++++++++++++++++++++ 12 files changed, 156 insertions(+), 176 deletions(-) create mode 100644 examples/declarative/tutorials/helloworld/Cell.qml delete mode 100644 examples/declarative/tutorials/helloworld/t1/tutorial1.qml delete mode 100644 examples/declarative/tutorials/helloworld/t2/Cell.qml delete mode 100644 examples/declarative/tutorials/helloworld/t2/tutorial2.qml delete mode 100644 examples/declarative/tutorials/helloworld/t3/Cell.qml delete mode 100644 examples/declarative/tutorials/helloworld/t3/tutorial3.qml create mode 100644 examples/declarative/tutorials/helloworld/tutorial1.qml create mode 100644 examples/declarative/tutorials/helloworld/tutorial2.qml create mode 100644 examples/declarative/tutorials/helloworld/tutorial3.qml diff --git a/doc/src/declarative/tutorial1.qdoc b/doc/src/declarative/tutorial1.qdoc index f46c59d..c9a1c5a 100644 --- a/doc/src/declarative/tutorial1.qdoc +++ b/doc/src/declarative/tutorial1.qdoc @@ -10,7 +10,7 @@ The picture below is a screenshot of this program. Here is the QML code for the application: -\snippet examples/declarative/tutorials/helloworld/t1/tutorial1.qml 0 +\snippet examples/declarative/tutorials/helloworld/tutorial1.qml 0 \section1 Walkthrough @@ -19,19 +19,20 @@ Here is the QML code for the application: First, we need to import the types that we need for this example. Most QML files will import the built-in QML types (like \l{Rectangle}, \l{Image}, ...) that come with Qt with: -\snippet examples/declarative/tutorials/helloworld/t1/tutorial1.qml 3 +\snippet examples/declarative/tutorials/helloworld/tutorial1.qml 3 \section2 Rectangle element -\snippet examples/declarative/tutorials/helloworld/t1/tutorial1.qml 1 +\snippet examples/declarative/tutorials/helloworld/tutorial1.qml 1 We declare a root element of type \l{Rectangle}. It is one of the basic building blocks you can use to create an application in QML. -We give it an \c{id} to be able to refer to it later. In this case, we call it \e page. We also set the \c width, \c height and \c color properties. +We give it an \c{id} to be able to refer to it later. In this case, we call it \e page. +We also set the \c width, \c height and \c color properties. The \l{Rectangle} element contains many other properties (such as \c x and \c y), but these are left at their default values. \section2 Text element -\snippet examples/declarative/tutorials/helloworld/t1/tutorial1.qml 2 +\snippet examples/declarative/tutorials/helloworld/tutorial1.qml 2 We add a \l Text element as a child of our root element that will display the text 'Hello world!'. @@ -44,13 +45,13 @@ In this case, we specify that our text element should be horizontally centered i \section2 Viewing the example -To view what you have created, run the qmlviewer (located in the \c bin directory) with your filename as the first argument. For example, to run the provided completed Tutorial 1 example from the install location, you would type: +To view what you have created, run the qmlviewer (located in the \c bin directory) with your filename as the first argument. +For example, to run the provided completed Tutorial 1 example from the install location, you would type: \code -bin/qmlviewer $QTDIR/examples/declarative/tutorials/helloworld/t1/tutorial1.qml +bin/qmlviewer $QTDIR/examples/declarative/tutorials/helloworld/tutorial1.qml \endcode [\l tutorial] [Next: \l tutorial2] */ - diff --git a/doc/src/declarative/tutorial2.qdoc b/doc/src/declarative/tutorial2.qdoc index 21b5ebd..a076a62 100644 --- a/doc/src/declarative/tutorial2.qdoc +++ b/doc/src/declarative/tutorial2.qdoc @@ -15,36 +15,36 @@ defined in its own QML file (for more details, see \l components). Here is the QML code for \c Cell.qml: -\snippet examples/declarative/tutorials/helloworld/t2/Cell.qml 0 +\snippet examples/declarative/tutorials/helloworld/Cell.qml 0 \section1 Walkthrough \section2 The Cell Component -\snippet examples/declarative/tutorials/helloworld/t2/Cell.qml 1 +\snippet examples/declarative/tutorials/helloworld/Cell.qml 1 The root element of our component is an \l Item with the \c id \e container. An \l Item is the most basic visual element in QML and is often used as a container for other elements. -\snippet examples/declarative/tutorials/helloworld/t2/Cell.qml 4 +\snippet examples/declarative/tutorials/helloworld/Cell.qml 4 We declare a \c color property. This property is accessible from \e outside our component, this allows us to instantiate the cells with different colors. This property is just an alias to an existing property - the color of the rectangle that compose the cell (see \l{Properties}). -\snippet examples/declarative/tutorials/helloworld/t2/Cell.qml 5 +\snippet examples/declarative/tutorials/helloworld/Cell.qml 5 We want our component to also have a signal that we call \e clicked with a \e color parameter. We will use this signal to change the color of the text in the main QML file later. -\snippet examples/declarative/tutorials/helloworld/t2/Cell.qml 2 +\snippet examples/declarative/tutorials/helloworld/Cell.qml 2 Our cell component is basically a colored rectangle with the \c id \e rectangle. The \c anchors.fill property is a convenient way to set the size of an element. In this case the rectangle will have the same size as its parent (see \l{anchor-layout}{Anchor-based Layout}). -\snippet examples/declarative/tutorials/helloworld/t2/Cell.qml 3 +\snippet examples/declarative/tutorials/helloworld/Cell.qml 3 In order to change the color of the text when clicking on a cell, we create a \l MouseRegion element with the same size as its parent. @@ -56,11 +56,11 @@ When this signal is triggered we want to emit our own \e clicked signal with the In our main QML file, we use our \c Cell component to create the color picker: -\snippet examples/declarative/tutorials/helloworld/t2/tutorial2.qml 0 +\snippet examples/declarative/tutorials/helloworld/tutorial2.qml 0 We create the color picker by putting 6 cells with different colors in a grid. -\snippet examples/declarative/tutorials/helloworld/t2/tutorial2.qml 1 +\snippet examples/declarative/tutorials/helloworld/tutorial2.qml 1 When the \e clicked signal of our cell is triggered, we want to set the color of the text to the color passed as a parameter. We can react to any signal of our component through a property of the name \e 'onSignalName' (see \l{Signal Handlers}). diff --git a/doc/src/declarative/tutorial3.qdoc b/doc/src/declarative/tutorial3.qdoc index 21b7ae5..d766015 100644 --- a/doc/src/declarative/tutorial3.qdoc +++ b/doc/src/declarative/tutorial3.qdoc @@ -11,11 +11,11 @@ We want our text to move to the bottom of the screen, rotate and become red when Here is the QML code: -\snippet examples/declarative/tutorials/helloworld/t3/tutorial3.qml 0 +\snippet examples/declarative/tutorials/helloworld/tutorial3.qml 0 \section1 Walkthrough -\snippet examples/declarative/tutorials/helloworld/t3/tutorial3.qml 2 +\snippet examples/declarative/tutorials/helloworld/tutorial3.qml 2 First, we create a new \e down state for our text element. This state will be activated when the \l MouseRegion is pressed, and deactivated when it is released. @@ -24,7 +24,7 @@ The \e down state includes a set of property changes from our implicit \e {defau (the items as they were initially defined in the QML). Specifically, we set the \c y property of the text to \c 160, the rotation to \c 180 and the \c color to red. -\snippet examples/declarative/tutorials/helloworld/t3/tutorial3.qml 3 +\snippet examples/declarative/tutorials/helloworld/tutorial3.qml 3 Because we don't want the text to appear at the bottom instantly but rather move smoothly, we add a transition between our two states. @@ -44,4 +44,3 @@ For more details on states and transitions, see \l {states-transitions}{States a [Previous: \l tutorial2] [\l tutorial] */ - diff --git a/examples/declarative/tutorials/helloworld/Cell.qml b/examples/declarative/tutorials/helloworld/Cell.qml new file mode 100644 index 0000000..ab6e565 --- /dev/null +++ b/examples/declarative/tutorials/helloworld/Cell.qml @@ -0,0 +1,32 @@ +//![0] +import Qt 4.6 + +//![1] +Item { + id: container +//![4] + property alias color: rectangle.color +//![4] +//![5] + signal clicked(string color) +//![5] + + width: 40; height: 25 +//![1] + +//![2] + Rectangle { + id: rectangle + border.color: "white" + anchors.fill: parent + } +//![2] + +//![3] + MouseRegion { + anchors.fill: parent + onClicked: container.clicked(container.color) + } +//![3] +} +//![0] diff --git a/examples/declarative/tutorials/helloworld/t1/tutorial1.qml b/examples/declarative/tutorials/helloworld/t1/tutorial1.qml deleted file mode 100644 index 93d3c34..0000000 --- a/examples/declarative/tutorials/helloworld/t1/tutorial1.qml +++ /dev/null @@ -1,22 +0,0 @@ -//![0] -//![3] -import Qt 4.6 -//![3] - -//![1] -Rectangle { - id: page - width: 500; height: 200 - color: "lightgray" -//![1] - -//![2] - Text { - id: helloText - text: "Hello world!" - font.pointSize: 24; font.bold: true - y: 30; anchors.horizontalCenter: page.horizontalCenter - } -//![2] -} -//![0] diff --git a/examples/declarative/tutorials/helloworld/t2/Cell.qml b/examples/declarative/tutorials/helloworld/t2/Cell.qml deleted file mode 100644 index ab6e565..0000000 --- a/examples/declarative/tutorials/helloworld/t2/Cell.qml +++ /dev/null @@ -1,32 +0,0 @@ -//![0] -import Qt 4.6 - -//![1] -Item { - id: container -//![4] - property alias color: rectangle.color -//![4] -//![5] - signal clicked(string color) -//![5] - - width: 40; height: 25 -//![1] - -//![2] - Rectangle { - id: rectangle - border.color: "white" - anchors.fill: parent - } -//![2] - -//![3] - MouseRegion { - anchors.fill: parent - onClicked: container.clicked(container.color) - } -//![3] -} -//![0] diff --git a/examples/declarative/tutorials/helloworld/t2/tutorial2.qml b/examples/declarative/tutorials/helloworld/t2/tutorial2.qml deleted file mode 100644 index 99889d7..0000000 --- a/examples/declarative/tutorials/helloworld/t2/tutorial2.qml +++ /dev/null @@ -1,31 +0,0 @@ -//![0] -import Qt 4.6 - -Rectangle { - id: page - width: 500; height: 200 - color: "lightgray" - - Text { - id: helloText - text: "Hello world!" - font.pointSize: 24; font.bold: true - y: 30; anchors.horizontalCenter: page.horizontalCenter - } - - Grid { - id: colorPicker - anchors.bottom: page.bottom - rows: 2; columns: 3; spacing: 3 - -//![1] - Cell { color: "red"; onClicked: helloText.color = color } -//![1] - Cell { color: "green"; onClicked: helloText.color = color } - Cell { color: "blue"; onClicked: helloText.color = color } - Cell { color: "yellow"; onClicked: helloText.color = color } - Cell { color: "steelblue"; onClicked: helloText.color = color } - Cell { color: "black"; onClicked: helloText.color = color } - } -} -//![0] diff --git a/examples/declarative/tutorials/helloworld/t3/Cell.qml b/examples/declarative/tutorials/helloworld/t3/Cell.qml deleted file mode 100644 index 578369d..0000000 --- a/examples/declarative/tutorials/helloworld/t3/Cell.qml +++ /dev/null @@ -1,20 +0,0 @@ -import Qt 4.6 - -Item { - id: container - property alias color: rectangle.color - signal clicked(string color) - - width: 40; height: 25 - - Rectangle { - id: rectangle - border.color: "white" - anchors.fill: parent - } - - MouseRegion { - anchors.fill: parent - onClicked: container.clicked(container.color) - } -} diff --git a/examples/declarative/tutorials/helloworld/t3/tutorial3.qml b/examples/declarative/tutorials/helloworld/t3/tutorial3.qml deleted file mode 100644 index d641eba..0000000 --- a/examples/declarative/tutorials/helloworld/t3/tutorial3.qml +++ /dev/null @@ -1,51 +0,0 @@ -//![0] -import Qt 4.6 - -Rectangle { - id: page - width: 500; height: 200 - color: "lightgray" - - Text { - id: helloText - text: "Hello world!" - font.pointSize: 24; font.bold: true - y: 30; anchors.horizontalCenter: page.horizontalCenter - transformOrigin: "Center" - -//![1] - MouseRegion { id: mouseRegion; anchors.fill: parent } -//![1] - -//![2] - states: State { - name: "down"; when: mouseRegion.pressed == true - PropertyChanges { target: helloText; y: 160; rotation: 180; color: "red" } - } -//![2] - -//![3] - transitions: Transition { - from: ""; to: "down"; reversible: true - ParallelAnimation { - NumberAnimation { properties: "y,rotation"; duration: 500; easing: "easeInOutQuad" } - ColorAnimation { property: "color"; duration: 500 } - } - } -//![3] - } - - Grid { - id: colorPicker - anchors.bottom: page.bottom - rows: 2; columns: 3; spacing: 3 - - Cell { color: "red"; onClicked: helloText.color = color } - Cell { color: "green"; onClicked: helloText.color = color } - Cell { color: "blue"; onClicked: helloText.color = color } - Cell { color: "yellow"; onClicked: helloText.color = color } - Cell { color: "steelblue"; onClicked: helloText.color = color } - Cell { color: "black"; onClicked: helloText.color = color } - } -} -//![0] diff --git a/examples/declarative/tutorials/helloworld/tutorial1.qml b/examples/declarative/tutorials/helloworld/tutorial1.qml new file mode 100644 index 0000000..93d3c34 --- /dev/null +++ b/examples/declarative/tutorials/helloworld/tutorial1.qml @@ -0,0 +1,22 @@ +//![0] +//![3] +import Qt 4.6 +//![3] + +//![1] +Rectangle { + id: page + width: 500; height: 200 + color: "lightgray" +//![1] + +//![2] + Text { + id: helloText + text: "Hello world!" + font.pointSize: 24; font.bold: true + y: 30; anchors.horizontalCenter: page.horizontalCenter + } +//![2] +} +//![0] diff --git a/examples/declarative/tutorials/helloworld/tutorial2.qml b/examples/declarative/tutorials/helloworld/tutorial2.qml new file mode 100644 index 0000000..99889d7 --- /dev/null +++ b/examples/declarative/tutorials/helloworld/tutorial2.qml @@ -0,0 +1,31 @@ +//![0] +import Qt 4.6 + +Rectangle { + id: page + width: 500; height: 200 + color: "lightgray" + + Text { + id: helloText + text: "Hello world!" + font.pointSize: 24; font.bold: true + y: 30; anchors.horizontalCenter: page.horizontalCenter + } + + Grid { + id: colorPicker + anchors.bottom: page.bottom + rows: 2; columns: 3; spacing: 3 + +//![1] + Cell { color: "red"; onClicked: helloText.color = color } +//![1] + Cell { color: "green"; onClicked: helloText.color = color } + Cell { color: "blue"; onClicked: helloText.color = color } + Cell { color: "yellow"; onClicked: helloText.color = color } + Cell { color: "steelblue"; onClicked: helloText.color = color } + Cell { color: "black"; onClicked: helloText.color = color } + } +} +//![0] diff --git a/examples/declarative/tutorials/helloworld/tutorial3.qml b/examples/declarative/tutorials/helloworld/tutorial3.qml new file mode 100644 index 0000000..d641eba --- /dev/null +++ b/examples/declarative/tutorials/helloworld/tutorial3.qml @@ -0,0 +1,51 @@ +//![0] +import Qt 4.6 + +Rectangle { + id: page + width: 500; height: 200 + color: "lightgray" + + Text { + id: helloText + text: "Hello world!" + font.pointSize: 24; font.bold: true + y: 30; anchors.horizontalCenter: page.horizontalCenter + transformOrigin: "Center" + +//![1] + MouseRegion { id: mouseRegion; anchors.fill: parent } +//![1] + +//![2] + states: State { + name: "down"; when: mouseRegion.pressed == true + PropertyChanges { target: helloText; y: 160; rotation: 180; color: "red" } + } +//![2] + +//![3] + transitions: Transition { + from: ""; to: "down"; reversible: true + ParallelAnimation { + NumberAnimation { properties: "y,rotation"; duration: 500; easing: "easeInOutQuad" } + ColorAnimation { property: "color"; duration: 500 } + } + } +//![3] + } + + Grid { + id: colorPicker + anchors.bottom: page.bottom + rows: 2; columns: 3; spacing: 3 + + Cell { color: "red"; onClicked: helloText.color = color } + Cell { color: "green"; onClicked: helloText.color = color } + Cell { color: "blue"; onClicked: helloText.color = color } + Cell { color: "yellow"; onClicked: helloText.color = color } + Cell { color: "steelblue"; onClicked: helloText.color = color } + Cell { color: "black"; onClicked: helloText.color = color } + } +} +//![0] -- cgit v0.12 From 68573410fb50d95a6ce27cd001d2e140b0b4aedd Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Wed, 7 Oct 2009 17:56:09 +1000 Subject: doc cleanup --- doc/src/declarative/anchor-layout.qdoc | 24 ++-- doc/src/declarative/animation.qdoc | 8 +- doc/src/declarative/basictypes.qdoc | 6 +- doc/src/declarative/binding.qdoc | 10 +- doc/src/declarative/extending.qdoc | 252 ++++++++++++++++----------------- doc/src/declarative/focus.qdoc | 38 ++--- doc/src/declarative/qmlforcpp.qdoc | 218 ++++++++++++++-------------- doc/src/declarative/qmlformat.qdoc | 76 +++++----- doc/src/declarative/qmlintro.qdoc | 12 +- 9 files changed, 322 insertions(+), 322 deletions(-) diff --git a/doc/src/declarative/anchor-layout.qdoc b/doc/src/declarative/anchor-layout.qdoc index f3c0f4a..e723d5c 100644 --- a/doc/src/declarative/anchor-layout.qdoc +++ b/doc/src/declarative/anchor-layout.qdoc @@ -10,11 +10,11 @@ In addition to the more traditional \l Grid, \l Row, and \l Column, QML also pro The QML anchoring system allows you to define relationships between the anchor lines of different items. For example, you can write: \code -Rectangle { id: Rect1; ... } -Rectangle { id: Rect2; anchors.left: Rect1.right; ... } +Rectangle { id: rect1; ... } +Rectangle { id: rect2; anchors.left: rect1.right; ... } \endcode -In this case, the left edge of \e Rect2 is bound to the right edge of Rect1, producing the following: +In this case, the left edge of \e rect2 is bound to the right edge of rect1, producing the following: \image edge1.png @@ -25,19 +25,19 @@ The anchoring system also allows you to specify margins and offsets. Margins spe The following example specifies a left margin: \code -Rectangle { id: Rect1; ... } -Rectangle { id: Rect2; anchors.left: Rect1.right; anchors.leftMargin: 5; ... } +Rectangle { id: rect1; ... } +Rectangle { id: rect2; anchors.left: rect1.right; anchors.leftMargin: 5; ... } \endcode -In this case, a margin of 5 pixels is reserved to the left of \e Rect2, producing the following: +In this case, a margin of 5 pixels is reserved to the left of \e rect2, producing the following: \image edge2.png You can specify multiple anchors. For example: \code -Rectangle { id: Rect1; ... } -Rectangle { id: Rect2; anchors.left: Rect1.right; anchors.top: Rect1.bottom; ... } +Rectangle { id: rect1; ... } +Rectangle { id: rect2; anchors.left: rect1.right; anchors.top: rect1.bottom; ... } \endcode \image edge3.png @@ -45,8 +45,8 @@ Rectangle { id: Rect2; anchors.left: Rect1.right; anchors.top: Rect1.bottom; ... By specifying multiple horizontal or vertical anchors you can control the size of an item. For example: \code -Rectangle { id: Rect1; x: 0; ... } -Rectangle { id: Rect2; anchors.left: Rect1.right; anchors.right: Rect3.left; ... } +Rectangle { id: rect1; x: 0; ... } +Rectangle { id: rect2; anchors.left: rect1.right; anchors.right: Rect3.left; ... } Rectangle { id: Rect3; x: 150; ... } \endcode @@ -59,11 +59,11 @@ For performance reasons, you can only anchor an item to its siblings and direct \badcode Item { id: Group1 - Rectangle { id: Rect1; ... } + Rectangle { id: rect1; ... } } Item { id: Group2 - Rectangle { id: Rect2; anchors.left: Rect1.right; ... } // invalid anchor! + Rectangle { id: rect2; anchors.left: rect1.right; ... } // invalid anchor! } \endcode diff --git a/doc/src/declarative/animation.qdoc b/doc/src/declarative/animation.qdoc index 9554ad5..21263c1 100644 --- a/doc/src/declarative/animation.qdoc +++ b/doc/src/declarative/animation.qdoc @@ -1,10 +1,10 @@ -/*! +/*! \page qmlanimation.html \target qmlanimation \title QML Animation -QML supports three different forms of animation - basic property animation, -states and transitions and property behaviors. +QML supports three different forms of animation - basic property animation, +states and transitions and property behaviors. \section1 Property Animation @@ -122,7 +122,7 @@ QML transitions can use selectors to determine which state changes a transition \code Transition { from: "*" - to: "Details" + to: "details" ... } \endcode diff --git a/doc/src/declarative/basictypes.qdoc b/doc/src/declarative/basictypes.qdoc index ae942fc..6feb91b 100644 --- a/doc/src/declarative/basictypes.qdoc +++ b/doc/src/declarative/basictypes.qdoc @@ -184,9 +184,9 @@ \qml Item { children: [ - Item { id: Child1 }, - Rectangle { id: Child2 }, - Text { id: Child3 } + Item { id: child1 }, + Rectangle { id: child2 }, + Text { id: child3 } ] } \endqml diff --git a/doc/src/declarative/binding.qdoc b/doc/src/declarative/binding.qdoc index e6835ee..99f2853 100644 --- a/doc/src/declarative/binding.qdoc +++ b/doc/src/declarative/binding.qdoc @@ -5,17 +5,17 @@ Data binding provides a declarative way of specifying the data associated with objects, as well as the relationship between data of different objects. For example, you could bind the text of a label to the value of a slider: as the value of the slider changed, the label would be automatically updated with the new value. -Bindings are created in QML when an expression is assigned to a property. For example, the following produces two rectangles of equal size (\c Rect2 is bound to the size of \c Rect1): +Bindings are created in QML when an expression is assigned to a property. For example, the following produces two rectangles of equal size (\c rect2 is bound to the size of \c rect1): \code -Rectangle { id: Rect1; width: 100; height: 100 } -Rectangle { id: Rect2; width: Rect1.width; height: Rect1.height } +Rectangle { id: rect1; width: 100; height: 100 } +Rectangle { id: rect2; width: rect1.width; height: rect1.height } \endcode There is also a special \l Binding element, which is typically used to bind from the UI to the underlying UI model (see \l {Passing Data Between C++ and QML} for an example of this). The bindings above could be expressed using the \l Binding element as: \code -Binding { target: Rect2; property: "width"; value: Rect1.width } -Binding { target: Rect2; property: "height"; value: Rect1.height } +Binding { target: rect2; property: "width"; value: rect1.width } +Binding { target: rect2; property: "height"; value: rect1.height } \endcode In addition to binding directly to a property, you can also bind to the results of expressions involving properties. For example: diff --git a/doc/src/declarative/extending.qdoc b/doc/src/declarative/extending.qdoc index 2d0dc34..649eab1 100644 --- a/doc/src/declarative/extending.qdoc +++ b/doc/src/declarative/extending.qdoc @@ -43,8 +43,8 @@ \page qml-extending.html \title Extending QML -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 +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 not conceptually limited to this: the QML format is an abstract description of any object tree. All the QML element types included in Qt are implemented using the C++ extension mechanisms describe on this page. Programmers can use these @@ -57,14 +57,14 @@ QML for their own independent use. \snippet examples/declarative/extending/adding/example.qml 0 -The QML snippet shown above instantiates one \c Person instance and sets +The QML snippet shown above instantiates one \c Person instance and sets the name and shoeSize properties on it. Everything in QML ultimately comes down -to either instantiating an object instance, or assigning a property a value. +to either instantiating an object instance, or assigning a property a value. QML relies heavily on Qt's meta object system and can only instantiate classes 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. +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: @@ -79,11 +79,11 @@ under the name \a QmlName in library URI version VMAJ.VFROM to VMAJ.VTO. \a T and \a QmlName may be the same. Generally the QML_DECLARE_TYPE() macro should be included immediately following -the type declaration (usually in its header file), and the QML_DEFINE_TYPE() +the type declaration (usually in its header file), and the QML_DEFINE_TYPE() macro in the implementation file. QML_DEFINE_TYPE() must not be present in a header file. -Type \a T must be a concrete type that inherits QObject and has a default +Type \a T must be a concrete type that inherits QObject and has a default constructor. \endquotation @@ -106,7 +106,7 @@ of these types: \endlist QML is typesafe. Attempting to assign an invalid value to a property will -generate an error. For example, assuming the name property of the \c Person +generate an error. For example, assuming the name property of the \c Person element had a type of QString, this would cause an error: \code @@ -127,13 +127,13 @@ The QML snippet shown above assigns a \c Person object to the \c BirthdayParty's celebrant property, and assigns three \c Person objects to the guests property. QML can set properties of types that are more complex than basic intrinsics like -integers and strings. Properties can also be object pointers, Qt interface -pointers, lists of object points, and lists of Qt interface pointers. As QML -is typesafe it ensures that only valid types are assigned to these properties, +integers and strings. Properties can also be object pointers, Qt interface +pointers, lists of object points, and lists of Qt interface pointers. As QML +is typesafe it ensures that only valid types are assigned to these properties, just like it does for primitive types. Properties that are pointers to objects or Qt interfaces are declared with the -Q_PROPERTY() macro, just like other properties. The celebrant property +Q_PROPERTY() macro, just like other properties. The celebrant property declaration looks like this: \snippet examples/declarative/extending/properties/birthdayparty.h 1 @@ -143,7 +143,7 @@ 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 +they cannot be instantiated directly, registering a Qt interface is different from registering a new QML type. The following macros are used instead: \quotation @@ -154,8 +154,8 @@ from registering a new QML type. The following macros are used instead: Register the C++ interface \a T with the QML system. -Generally the QML_DECLARE_INTERFACE() macro should be included immediately -following the interface declaration (usually in its header file), and the +Generally the QML_DECLARE_INTERFACE() macro should be included immediately +following the interface declaration (usually in its header file), and the QML_DEFINE_INTERFACE() macro in an implementation file. QML_DEFINE_INTERFACE() must not be present in a header file. @@ -163,7 +163,7 @@ Following registration, QML can coerce objects that implement this interface for assignment to appropriately typed properties. \endquotation -The guests property is a list of \c Person objects. Properties that are lists +The guests property is a list of \c Person objects. Properties that are lists of objects or Qt interfaces are also declared with the Q_PROPERTY() macro, just like other properties. List properties must have the type \c {QmlList*}. As with object properties, the type \a T must be registered with QML. @@ -172,7 +172,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 - Object and List Property Types Example} shows the complete code used to create the \c BirthdayParty type. \section1 Inheritance and Coercion @@ -182,17 +182,17 @@ code used to create the \c BirthdayParty type. The QML snippet shown above assigns a \c Boy object to the \c BirthdayParty's celebrant property, and assigns three other objects to the guests property. -QML supports C++ inheritance heirarchies and can freely coerce between known, +QML supports C++ inheritance heirarchies and can freely coerce between known, valid object types. This enables the creation of common base classes that allow the assignment of specialized classes to object or list properties. In the snippet shown, both the celebrant and the guests properties retain the Person -type used in the previous section, but the assignment is valid as both the Boy +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_DEFINE_TYPE() and QML_DEFINE_INTERFACE() macros 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 +as a base class that cannot be instantiated from QML needs to be registered these macros can be used: \quotation @@ -201,14 +201,14 @@ registered these macros can be used: #define QML_DEFINE_NOCREATE_TYPE(T) \endcode -Register the C++ type \a T with the QML system. QML_DEFINE_NOCREATE_TYPE() +Register the C++ type \a T with the QML system. QML_DEFINE_NOCREATE_TYPE() differs from QML_DEFINE_TYPE() in that it 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_DEFINE_NOCREATE_TYPE() macro in the implementation file. +the type declaration (usually in its header file), and the +QML_DEFINE_NOCREATE_TYPE() macro in the implementation file. QML_DEFINE_NOCREATE_TYPE() must not be present in a header file. Type \a T must inherit QObject, but there are no restrictions on whether it is @@ -216,25 +216,25 @@ concrete or the signature of its constructor. \endquotation 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 +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 - Inheritance and Coercion Example} shows the complete code used to create the \c Boy and \c Girl types. \section1 Default Property \snippet examples/declarative/extending/default/example.qml 0 -The QML snippet shown above assigns a collection of objects to the +The QML snippet shown above assigns a collection of objects to the \c BirthdayParty's default property. The default property is a syntactic convenience that allows a type designer to -specify a single property as the type's default. The default property is +specify a single property as the type's default. The default property is assigned to whenever no explicit property is specified. As a convenience, it is behaviorally identical to assigning the default property explicitly by name. -From C++, type designers mark the default property using a Q_CLASSINFO() +From C++, type designers mark the default property using a Q_CLASSINFO() annotation: \quotation @@ -245,7 +245,7 @@ Q_CLASSINFO("DefaultProperty", "property") Mark \a property as the class's default property. \a property must be either an object property, or a list property. -A default property is optional. A derived class inherits its base class's +A default property is optional. A derived class inherits its base class's default property, but may override it in its own declaration. \a property can refer to a property declared in the class itself, or a property inherited from a base class. @@ -261,9 +261,9 @@ specify a default property. The QML snippet shown above assigns a number properties to the \c Boy object, including four properties using the grouped property syntax. -Grouped properties collect similar properties together into a single named +Grouped properties collect similar properties together into a single named block. Grouped properties can be used to present a nicer API to developers, and -may also simplify the implementation of common property collections across +may also simplify the implementation of common property collections across different types through implementation reuse. A grouped property block is implemented as a read-only object property. The @@ -271,35 +271,35 @@ shoe property shown is declared like this: \snippet examples/declarative/extending/grouped/person.h 1 -The ShoeDescription type declares the properties available to the grouped +The ShoeDescription type declares the properties available to the grouped property block - in this case the size, color, brand and price properties. -Grouped property blocks may declared and accessed be recusively. +Grouped property blocks may declared and accessed be recusively. -\l {Extending QML - Grouped Properties Example} shows the complete code used to +\l {Extending QML - Grouped Properties Example} shows the complete code used to implement the \c shoe property grouping. \section1 Attached Properties \snippet examples/declarative/extending/attached/example.qml 1 -The QML snippet shown above assigns the rsvp property using the attached +The QML snippet shown above assigns the rsvp property using the attached property syntax. Attached properties allow unrelated types to annotate other types with some -additional properties, generally for their own use. Attached properties are -identified through the use of the attacher type name, in the case shown -\c BirthdayParty, as a suffix to the property name. +additional properties, generally for their own use. Attached properties are +identified through the use of the attacher type name, in the case shown +\c BirthdayParty, as a suffix to the property name. In the example shown, \c BirthdayParty is called the attaching type, and the -Box instance the attachee object instance. +Box instance the attachee object instance. For the attaching type, an attached property block is implemented as a new QObject derived type, called the attachment object. The properties on the -attachment object are those that become available for use as the attached +attachment object are those that become available for use as the attached property block. -Any QML type can become an attaching type by declaring the +Any QML type can become an attaching type by declaring the \c qmlAttachedProperties() public function: \quotation @@ -310,21 +310,21 @@ Return an attachment object, of type \a AttachedPropertiesType, for the attachee \a object instance. It is customary, though not strictly required, for the attachment object to be parented to \a object to prevent memory leaks. -\a AttachedPropertiesType must be a QObject derived type. The properties on +\a AttachedPropertiesType must be a QObject derived type. The properties on this type will be accessible through the attached properties syntax. This method will be called at most once for each attachee object instance. The -QML engine will cache the returned instance pointer for subsequent attached +QML engine will cache the returned instance pointer for subsequent attached property accesses. Consequently the attachment object may not be deleted until \a object is destroyed. \endquotation -Conceptually, attached properties are a \e type exporting a set of additional +Conceptually, attached properties are a \e type exporting a set of additional properties that can be set on \e any other object instance. Attached properties cannot be limited to only attaching to a sub-set of object instances, although their effect may be so limited. -For example, a common usage scenario is for a type to enhance the properties +For example, a common usage scenario is for a type to enhance the properties available to its children in order to gather instance specific data. Here we add a rsvp field to all the guests coming to a birthday party: \code @@ -332,7 +332,7 @@ BirthdayParty { Boy { BirthdayParty.rsvp: "2009-06-01" } } \endcode -However, as a type cannot limit the instances to which the attachment object +However, as a type cannot limit the instances to which the attachment object must attach, the following is also allowed, even though adding a birthday party rsvp in this context will have no effect. \code @@ -349,10 +349,10 @@ an instance can be accessed using the following method: template QObject *qmlAttachedPropertiesObject(QObject *attachee, bool create = true); \endcode -Returns the attachment object attached to \a attachee by the attaching type +Returns the attachment object attached to \a attachee by the attaching type \a T. If type \a T is not a valid attaching type, this method always returns 0. -If \a create is true, a valid attachment object will always be returned, +If \a create is true, a valid attachment object will always be returned, 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 @@ -368,8 +368,8 @@ implement the rsvp attached property. The QML snippet shown above associates the evaluation of a ECMAScript expression with the emission of a Qt signal. -All Qt signals on a registered class become available as special "signal -properties" within QML to which the user can assign a single ECMAScript +All Qt signals on a registered class become available as special "signal +properties" within QML to which the user can assign a single ECMAScript expression. The signal property's name is a transformed version of the Qt signal name: "on" is prepended, and the first letter of the signal name upper cased. For example, the signal used in the example above has the following @@ -378,14 +378,14 @@ C++ signature: \snippet examples/declarative/extending/signal/birthdayparty.h 0 In classes with multiple signals with the same name, only the final signal -is accessible as a signal property. Although QML provides an element, +is accessible as a signal property. Although QML provides an element, \l Connection, for accessing the other signals it is less elegant. For the best QML API, class developers should avoid overloading signal names. Signal parameters become accessible by name to the assigned script. An unnamed parameter cannot be accessed, so care should be taken to name all the signal parameters in the C++ class declaration. The intrinsic types -listed in \l {Adding Types}, as well registered object types are permitted as +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. @@ -400,14 +400,14 @@ implement the onPartyStarted signal property. The QML snippet shown above assigns a property value to the speaker property. A property value source generates a value for a property that changes over time. -Property value sources are most commonly used to do animation. Rather than +Property value sources are most commonly used to do animation. Rather than constructing an animation object and manually setting the animation's "target" property, a property value source can be assigned directly to a property of any type and automatically set up this association. -The example shown here is rather contrived: the speaker property of the +The example shown here is rather contrived: the speaker property of the BirthdayParty object is a string that is printed every time it is assigned and -the HappyBirthday value source generates the lyrics of the song +the HappyBirthday value source generates the lyrics of the song "Happy Birthday". \snippet examples/declarative/extending/valuesource/birthdayparty.h 0 @@ -417,9 +417,9 @@ the case of a property value source, rather than assigning the object instance itself, the QML engine sets up an association between the value source and the property. -Property value sources are special types that derive from the +Property value sources are special types that derive from the QmlPropertyValueSource base class. This base class contains a single method, -QmlPropertyValueSource::setTarget(), that the QML engine invokes when +QmlPropertyValueSource::setTarget(), that the QML engine invokes when associating the property value source with a property. The relevant part of the HappyBirthday type declaration looks like this: @@ -429,10 +429,10 @@ the HappyBirthday type declaration looks like this: In all other respects, property value sources are regular QML types. They must be registered with the QML engine using the same macros as other types, and can -contain properties, signals and methods just like other types. +contain properties, signals and methods just like other types. When a property value source object is assigned to a property, QML first tries -to assign it normally, as though it were a regular QML type. Only if this +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. @@ -444,20 +444,20 @@ implement the HappyBirthday property value source. \snippet examples/declarative/extending/binding/example.qml 0 \snippet examples/declarative/extending/binding/example.qml 1 -The QML snippet shown above uses a property binding to ensure the +The QML snippet shown above uses a property binding to ensure the HappyBirthday's name property remains up to date with the celebrant. Property binding is a core feature of QML. In addition to assigning literal -values, property bindings allow the developer to assign an arbitrarily complex +values, property bindings allow the developer to assign an arbitrarily complex ECMAScript expression that may include dependencies on other property values. -Whenever the expression's result changes - through a change in one of its +Whenever the expression's result changes - through a change in one of its constituent values - the expression is automatically reevaluated and the new result assigned to the property. All properties on custom types automatically support property binding. However, -for binding to work correctly, QML must be able to reliably determine when a +for binding to work correctly, QML must be able to reliably determine when a property has changed so that it knows to reevaluate any bindings that depend on -the property's value. QML relies on the presence of a +the property's value. QML relies on the presence of a \c {Qt's Property System}{NOTIFY signal} for this determination. Here is the celebrant property declaration: @@ -468,7 +468,7 @@ The NOTIFY attribute is followed by a signal name. It is the responsibility of the class implementer to ensure that whenever the property's value changes, the NOTIFY signal is emitted. The signature of the NOTIFY signal is not important to QML. -To prevent loops or excessive evaluation, developers should ensure that the +To prevent loops or excessive evaluation, developers should ensure that the signal is only emitted whenever the property's value is actually changed. If a property, or group of properties, is infrequently used it is permitted to use the same NOTIFY signal for several properties. This should be done with care to @@ -476,10 +476,10 @@ ensure that performance doesn't suffer. To keep QML reliable, if a property does not have a NOTIFY signal, it cannot be used in a binding expression. However, the property can still be assigned -a binding as QML does not need to monitor the property for change in that +a binding as QML does not need to monitor the property for change in that scenario. -Consider a custom type, \c TestElement, that has two properties, "a" and "b". +Consider a custom type, \c TestElement, that has two properties, "a" and "b". Property "a" does not have a NOTIFY signal, and property "b" does have a NOTIFY signal. @@ -495,7 +495,7 @@ TestElement { \endcode The presence of a NOTIFY signal does incur a small overhead. There are cases -where a property's value is set at object construction time, and does not +where a property's value is set at object construction time, and does not subsequently change. The most common case of this is when a type uses \l {Grouped Properties}, and the grouped property object is allocated once, and only freed when the object is deleted. In these cases, the CONSTANT attribute @@ -520,9 +520,9 @@ modifying its source code. When integrating existing classes and technology into QML, their APIs will often need to be tweaked to fit better into the declarative environment. Although -the best results are usually obtained by modifying the original classes -directly, if this is either not possible or is complicated by some other -concerns extension objects allow limited extension possibilities without +the best results are usually obtained by modifying the original classes +directly, if this is either not possible or is complicated by some other +concerns extension objects allow limited extension possibilities without direct modifications. Extension objects can only add properties. @@ -536,29 +536,29 @@ Extension objects can only add properties. \page qml-extending-types.html \title Extending types from QML -Many of the elements available for use in QML are implemented in -\l {QML for C++ Programmers}{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 +Many of the elements available for use in QML are implemented in +\l {QML for C++ Programmers}{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. \tableofcontents \section1 Adding new properties -New properties can be added to an existing type. These new properties are +New properties can be added to an existing type. These new properties are available for use within QML, and also appear as regular Qt properties on the C++ object, accessible through the regular property access mechanisms. -Like all properties in QML, custom properties are typed. The type is used to +Like all properties in QML, custom properties are typed. The type is used to define the property's behavior, and also determines the C++ type of the created -Qt property. The following table shows the list of types available when +Qt property. The following table shows the list of types available when declaring a new property, and the corresponding C++ type. \table -\header \o QML Type Name \o C++ Type Name -\row \o int \o int -\row \o bool \o bool +\header \o QML Type Name \o C++ Type Name +\row \o int \o int +\row \o bool \o bool \row \o double \o double \row \o real \o double \row \o string \o QString @@ -589,7 +589,7 @@ in the same type block is an error. However, a new property may reuse the name of an existing property on the type. This should be done with caution, as the existing property will be hidden, and become inaccessible. -The must be one of the QML type names shown in the above table. +The must be one of the QML type names shown in the above table. Additionally, an optional default value of the property can be provided. The default value is a convenient shortcut, but is behaviorally identical to doing it in two steps, like this: @@ -627,10 +627,10 @@ controls the color of the inner rectangle. \section2 Property aliases Property aliases are a more advanced form of property declaration. Unlike a -property definition, that allocates a new, unique storage space for the -property, a property alias connects the newly declared property (called the -aliasing property) to an existing property (the aliased property). Read -operations on the aliasing property act as read operations on the aliased +property definition, that allocates a new, unique storage space for the +property, a property alias connects the newly declared property (called the +aliasing property) to an existing property (the aliased property). Read +operations on the aliasing property act as read operations on the aliased property, and write operations on the aliasing property as write operations on the aliased property. @@ -641,7 +641,7 @@ A property alias declaration looks a lot like a property definition: As the aliasing property has the same type as the aliased property, an explicit type is omitted, and the special "alias" keyword is used. Instead of a default -value, a property alias includes a compulsary alias reference. The alias +value, a property alias includes a compulsary alias reference. The alias reference is used to locate the aliased property. While similar to a property binding, the alias reference syntax is highly restricted. @@ -656,11 +656,11 @@ alias reference syntax may become more flexibly in future releases. Here is the property definition example rewritten to use property aliases. \code Rectangle { - property alias innerColor: InnerRect.color + property alias innerColor: innerRect.color color: "red"; width: 100; height: 100 Rectangle { - id: InnerRect + id: innerRect anchors.centerIn: parent width: parent.width - 10 height: parent.height - 10 @@ -678,24 +678,24 @@ use the aliased property directly. For example, this will not work: \code // Does NOT work - property alias innerColor: InnerRect.color + property alias innerColor: innerRect.color innerColor: "black" \endcode -This behavior is required to allow type developers to redefine the behavior +This behavior is required to allow type developers to redefine the behavior of existing property names while continuing to use the existing behavior within -the type they are building, something that is not possible with property +the type they are building, something that is not possible with property definitions. In the example used so far, this could allows the developer to fix -the external rectangle's color as "red" and redefine the "color" property to +the external rectangle's color as "red" and redefine the "color" property to refer to the inner rectangle, like this: \code Rectangle { - property alias color: InnerRect.color + property alias color: innerRect.color color: "red"; width: 100; height: 100 Rectangle { - id: InnerRect + id: innerRect anchors.centerIn: parent width: parent.width - 10 height: parent.height - 10 @@ -705,18 +705,18 @@ Rectangle { \endcode Users of this type would not be able to affect the color of the red rectangle, -but would find using the "color" property, rather than the strange new +but would find using the "color" property, rather than the strange new "innerColor" property, much more familiar. -A second, much less significant, consequence of the delayed activation of +A second, much less significant, consequence of the delayed activation of aliases is that an alias reference cannot refer to another aliasing property declared within the same component. This will not work: \code // Does NOT work - id: Root - property alias innerColor: InnerRect.color - property alias innerColor2: Root.innerColor + id: root + property alias innerColor: innerRect.color + property alias innerColor2: root.innerColor \endcode From outside the component, aliasing properties appear as regular Qt properties @@ -724,7 +724,7 @@ and consequently can be used in alias references. \section1 Adding new signals -New signals can be added to an existing type. These new signals are available +New signals can be added to an existing type. These new signals are available for use within QML, and also appear as regular Qt signals on the C++ object that can be used in Qt signal/slot connections. @@ -734,9 +734,9 @@ signal [([ [, ...]])] \endcode This declaration may appear anywhere within a type body, but it is customary to -include it at the top. 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, +include it at the top. 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. The options for parameter types are the same as for property types (see @@ -754,7 +754,7 @@ Here are three examples of signal declarations: \section1 Adding new methods -New methods can be added to an existing type. These new methods are available +New methods can be added to an existing type. These new methods are available for use within QML, and also appear as regular Qt slots on the C++ object that can be used in Qt signal/slot connections. @@ -763,9 +763,9 @@ function ([[, ...]]) { } \endcode This declaration may appear anywhere within a type body, but it is customary to -include it at the top. Attempting to declare two methods or signals with the +include it at the top. 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, +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. Methods parameters are not typed. In C++ these parameters are of type QVariant. @@ -783,24 +783,24 @@ Item { \section1 Defining new Components -A component is a reusable type with a well-defined interface built entirely in +A component is a reusable type with a well-defined interface built entirely in QML. Components appear as regular QML elements, and can be used interchangably with core types. Components allow developers to create new types to be reused -in other projects without the use of C++. Components can also help to reduce -duplication inside one project by limiting the need for large numbers of +in other projects without the use of C++. Components can also help to reduce +duplication inside one project by limiting the need for large numbers of copy-and-pasted blocks. -Any snippet of QML code can become a component, just by placing it in the file +Any snippet of QML code can become a component, just by placing it in the file ".qml" where is the new element name, and begins with an uppercase letter. These QML files automatically become available as new QML element types to other QML components and applications in the same directory. -For example, here we show how a component named "Box" is defined and used +For example, here we show how a component named "Box" is defined and used multiple times by an application. \table \row -\o application.qml +\o application.qml \code Rectangle { width: 100; height: 400; @@ -812,19 +812,19 @@ Rectangle { \o Box.qml \code Rectangle { - width: 100; height: 100; + width: 100; height: 100; color: "blue" } \endcode \endtable -Components may be collected into \l {Modules} that gives the +Components may be collected into \l {Modules} that gives the developer more freedom than just putting files in the same directory. \section2 Building reusable components -A component type built to be reused by others must have a well defined -interface. In QML, an interface consists of a defined collection of +A component type built to be reused by others must have a well defined +interface. In QML, an interface consists of a defined collection of properties, signals and methods. Users of a component have access to all the properties, signals and methods defined on the root element of the component. @@ -846,7 +846,7 @@ available externally. Here we add a "text" property: \table \row -\o application.qml +\o application.qml \code Rectangle { width: 100; height: 400; @@ -858,25 +858,25 @@ Rectangle { \o Box.qml \code Rectangle { - property alias text: MyText.text - width: 100; height: 100; + property alias text: myText.text + width: 100; height: 100; color: "blue" Text { - id: MyText + id: myText anchors.centerIn: parent - } + } } \endcode \endtable Methods and signals may be added in the same way. -As all external methods, signals and properties are accessible to external -users, developers should ensure that setting these properties does not have +As all external methods, signals and properties are accessible to external +users, developers should ensure that setting these properties does not have any undesirable side-effects. For most resiliance, root level properties should only be used for literal default values. When a root level property must be used inside the component - such as the children property - property aliases can be used to redirect this property to a "safe" location for external users. -Try to think of the root level properties as being "owned" by the components +Try to think of the root level properties as being "owned" by the components user, rather than the component itself. */ diff --git a/doc/src/declarative/focus.qdoc b/doc/src/declarative/focus.qdoc index 028b5f0..1e00bd9 100644 --- a/doc/src/declarative/focus.qdoc +++ b/doc/src/declarative/focus.qdoc @@ -58,12 +58,12 @@ the \c {KeyActions} element has \e {active focus} and pressing the \o \code Rectangle { color: "lightsteelblue"; width: 240; height: 25 - Text { id: MyText } + Text { id: myText } KeyActions { focus: true - keyA: "MyText.text = 'Key A was pressed'" - keyB: "MyText.text = 'Key B was pressed'" - keyC: "MyText.text = 'Key C was pressed'" + keyA: "myText.text = 'Key A was pressed'" + keyB: "myText.text = 'Key B was pressed'" + keyC: "myText.text = 'Key C was pressed'" } } \endcode @@ -92,23 +92,23 @@ Rectangle { color: "red"; width: 240; height: 55 Rectangle { color: "lightsteelblue"; width: 240; height: 25 - Text { id: MyText } + Text { id: myText } KeyActions { focus: true - keyA: "MyText.text = 'Key A was pressed'" - keyB: "MyText.text = 'Key B was pressed'" - keyC: "MyText.text = 'Key C was pressed'" + keyA: "myText.text = 'Key A was pressed'" + keyB: "myText.text = 'Key B was pressed'" + keyC: "myText.text = 'Key C was pressed'" } } Rectangle { y: 30; focus: true color: "lightsteelblue"; width: 240; height: 25 - Text { id: MyText } + Text { id: myText } KeyActions { focus: true - keyA: "MyText.text = 'Key A was pressed'" - keyB: "MyText.text = 'Key B was pressed'" - keyC: "MyText.text = 'Key C was pressed'" + keyA: "myText.text = 'Key A was pressed'" + keyB: "myText.text = 'Key B was pressed'" + keyC: "myText.text = 'Key C was pressed'" } } } @@ -149,12 +149,12 @@ FocusScope { width: 240; height: 25 Rectangle { color: "lightsteelblue"; width: 240; height: 25 - Text { id: MyText } + Text { id: myText } KeyActions { focus: true - keyA: "MyText.text = 'Key A was pressed'" - keyB: "MyText.text = 'Key B was pressed'" - keyC: "MyText.text = 'Key C was pressed'" + keyA: "myText.text = 'Key A was pressed'" + keyB: "myText.text = 'Key B was pressed'" + keyC: "myText.text = 'Key C was pressed'" } } } @@ -186,9 +186,9 @@ Rectangle { \endcode \o \code FocusScope { - id: Page; width: 240; height: 25 + id: page; width: 240; height: 25 MyWidget { focus: true } - MouseRegion { anchors.fill: parent; onClicked: { Page.focus = true } } + MouseRegion { anchors.fill: parent; onClicked: { page.focus = true } } } \endcode \endtable @@ -221,7 +221,7 @@ Rectangle { color: "lightsteelblue"; width: 240; height: 320 ListView { - id: MyView; anchors.fill: parent; focus: true + id: myView; anchors.fill: parent; focus: true model: ListModel { ListElement { name: "Bob" } ListElement { name: "John" } diff --git a/doc/src/declarative/qmlforcpp.qdoc b/doc/src/declarative/qmlforcpp.qdoc index ab456e5..697ea59 100644 --- a/doc/src/declarative/qmlforcpp.qdoc +++ b/doc/src/declarative/qmlforcpp.qdoc @@ -6,13 +6,13 @@ This page describes the QML format and how to use and extend it from C++. The QML syntax declaratively describes how to construct an in memory - object tree. QML is usually used to describe a visual scene graph - but it is not conceptually limited to this: the QML format is an abstract - description of \bold any object tree. + object tree. QML is usually used to describe a visual scene graph + but it is not conceptually limited to this: the QML format is an abstract + description of \bold any object tree. - QML also includes property bindings. Bindings are ECMAScript expressions - of a properties value. Whenever the value of the expression changes - - either for the first time at startup or subsequently thereafter - the + QML also includes property bindings. Bindings are ECMAScript expressions + of a properties value. Whenever the value of the expression changes - + either for the first time at startup or subsequently thereafter - the property is automatically updated with the new value. \tableofcontents @@ -21,10 +21,10 @@ QmlComponent is used to load a QML file and to create object instances. - In QML a component is the unit of instantiation, and the most basic unit - of scope. A component is like a template for how to construct an object - tree. One component can create multiple instances of this tree, but the - template remains constant. + In QML a component is the unit of instantiation, and the most basic unit + of scope. A component is like a template for how to construct an object + tree. One component can create multiple instances of this tree, but the + template remains constant. The following code uses the C++ interface to create 100 red rectangles based on a simple declarative component description. @@ -37,10 +37,10 @@ // ... do something with the rectangle ... } \endcode - + Each independent file describes a QML component, but it is also possible to create sub-components within a QML file as will be shown later. - + \section1 QML Format 101 This is some sample QML code. @@ -64,8 +64,8 @@ } \endcode - The QML snippet shown above instantiates one \c Image instance and one - \c Text instance and sets properties on both. \bold Everything in QML + The QML snippet shown above instantiates one \c Image instance and one + \c Text instance and sets properties on both. \bold Everything in QML ultimately comes down to either instantiating an object instance, or assigning a property a value. QML relies heavily on Qt's meta object system and can only instantiate classes that derive from QObject. @@ -83,26 +83,26 @@ } \endcode - QML can set properties that are more complex than just simple types like - integers and strings. Properties can be object pointers or Qt interface + QML can set properties that are more complex than just simple types like + integers and strings. Properties can be object pointers or Qt interface pointers or even lists of object or Qt interface pointers! QML is typesafe, and will ensure that only the valid types are assigned to properties. Assigning an object to a property is as simple as assigning a basic - integer. Attempting to assign an object to a property when type coercian + integer. Attempting to assign an object to a property when type coercian fails will produce an error. The following shows an example of valid and of invalid QML and the corresponding C++ classes. \table \row \o - \code + \code class Image : public QObject { - ... + ... Q_PROPERTY(ImageFilter *filter READ filter WRITE setFilter) - }; + }; - class ImageFilter : public QObject + class ImageFilter : public QObject { ... }; @@ -121,11 +121,11 @@ \endtable Classes can also define an optional default property. The default property - is used for assignment if no explicit property has been specified. + is used for assignment if no explicit property has been specified. Any object property can be the default, even complex properties like lists - of objects. The default property of the \c Rect class is the \c children - property, a list of \c Item's. In the following example, as both \c Image - and \c Text inherit from \c Item the \c Image and \c Text instances are + of objects. The default property of the \c Rect class is the \c children + property, a list of \c Item's. In the following example, as both \c Image + and \c Text inherit from \c Item the \c Image and \c Text instances are added to the parent's \c children property. \code @@ -135,10 +135,10 @@ } \endcode - Properties that return read-only object pointers can be used recursively. - This can be used, for example, to group properties together. The + Properties that return read-only object pointers can be used recursively. + This can be used, for example, to group properties together. The \c Text element has a \c font property that returns an object with a number - of sub-properties such as \c family, \c bold, \c italic and \c size. + of sub-properties such as \c family, \c bold, \c italic and \c size. QML makes it easy to interact with these grouped properties, as the following shows - everything you would expect to work, just does. @@ -150,7 +150,7 @@ ... Q_PROPERTY(Font *font READ font); }; - class Font : public QObject + class Font : public QObject { ... Q_PROPERTY(QString family READ family WRITE setFamily); @@ -177,36 +177,36 @@ The QML engine has no intrinsic knowledge of any class types. Instead the programmer must define the C++ types, their corresponding QML name, library namespace, and version availability. - + \code #define QML_DECLARE_TYPE(T) #define QML_DEFINE_TYPE(URI,VMAJ,VFROM,VTO,QmlName,T) \endcode - Adding these macros to your library or executable automatically makes the + Adding these macros to your library or executable automatically makes the C++ type \a T available from the declarative markup language under the name \a QmlName. Of course there's nothing stopping you using the same name for both the C++ and the QML name! - Any type can be added to the QML engine using these macros. The only + Any type can be added to the QML engine using these macros. The only requirements are that \a T inherits QObject, is not abstract, and that it has a default constructor. - \section1 Property Binding + \section1 Property Binding Assigning constant values and trees to properties will only get you so - far. Property binding allows a property's value to be dependant on the + far. Property binding allows a property's value to be dependant on the value of other properties and data. Whenever these dependencies change, - the property's value is automatically updated. + the property's value is automatically updated. - Property bindings are ECMAScript expressions and can be applied to any - object property. C++ classes don't have to do anything special to get + Property bindings are ECMAScript expressions and can be applied to any + object property. C++ classes don't have to do anything special to get binding support other than define appropriate properties. When a non-literal - property assignment appears in a QML file, it is automatically treated as a + property assignment appears in a QML file, it is automatically treated as a property binding. - Here's a simple example that stacks a red, blue and green rectangle. + Here's a simple example that stacks a red, blue and green rectangle. Bindings are used to ensure that the height of each is kept equal to it's - parent's. Were the root rectangle's height property to change, the child + parent's. Were the root rectangle's height property to change, the child rectangles height would be updated automatically. \code @@ -230,25 +230,25 @@ defines how the expression resolves property and variable names. Although the two expressions in the last example are the same, the value of \c parent resolves differently because each executes in a different context. Although - QML generally takes care of everything for the programmer, a thorough + QML generally takes care of everything for the programmer, a thorough understanding of bind contexts is important in some of the more complex QML structures. - Every expression is executed in a bind context, encapsulated by the - QmlContext C++ class. As covered in the class documentation, a - bind context contains a map of names to values, and a list of default + Every expression is executed in a bind context, encapsulated by the + QmlContext C++ class. As covered in the class documentation, a + bind context contains a map of names to values, and a list of default objects. When resolving a name, the name to value map is searched first. - If the name cannot be found, the default object's are iterated in turn and + If the name cannot be found, the default object's are iterated in turn and the context attempts to resolve the name as a property of one of the default objects. There are generally two contexts involved in the execution of a binding. - The first is the "object context" - a bind context associated with the - closest instantiated object and containing just one default object, and + The first is the "object context" - a bind context associated with the + closest instantiated object and containing just one default object, and that's instantiated object itself. The effect of the object - context is pretty simple - names in the binding expression resolve to - properties on the object first. It is important to note - particularly in - the case of grouped properties - the object context is that of the + context is pretty simple - names in the binding expression resolve to + properties on the object first. It is important to note - particularly in + the case of grouped properties - the object context is that of the instantiated object, the consequences of which are shown below. \code @@ -260,7 +260,7 @@ } } \endcode - The second context is the "component context". Each QML component (and + The second context is the "component context". Each QML component (and consequently each QML file) is created in its own unique binding context. Like the object context, the component context contains just one default object - but in this case it is the component's root object. An example @@ -288,7 +288,7 @@ Rectangle { color: "red" width: 100 - Rectangle { + Rectangle { color: "blue" width: 50 height: parent.height @@ -301,13 +301,13 @@ } \endcode - Clearly this sort of fragile relationship is undesirable and unmanageable - - moving the green rectangle to be a sibling of the blue or introducing a + Clearly this sort of fragile relationship is undesirable and unmanageable - + moving the green rectangle to be a sibling of the blue or introducing a further rectangle between the two would break the example. To address this problem, QML includes a way to directly reference any object - within a component (or parent component for that matter), called "ids". - Developers assign an object an id, and can then reference it directly by + within a component (or parent component for that matter), called "ids". + Developers assign an object an id, and can then reference it directly by name. Developers assign an object an id by setting the special \c id property. Every object automatically has this magical property (if the object also has an actual property called \c id, that gets set too). As @@ -316,18 +316,18 @@ \code Rectangle { - id: Root + id: root color: "red" - width: GreenRect.width + 75 - height: Root.height + width: greenRect.width + 75 + height: root.height Rectangle { color: "blue" - width: GreenRect.width + 25 + width: greenRect.width + 25 Rectangle { - id: GreenRect + id: greenRect color: "green" width: 25 - height: Root.height + height: root.height } } } @@ -336,11 +336,11 @@ To relate id's back to QmlContext, id's exist as properties on the component context. - Bind expressions can reference any object property. The QML bind engine - relies on the presence of the NOTIFY signal in the Q_PROPERTY declaration - on a class to alert it that a property's value has changed. If this is + Bind expressions can reference any object property. The QML bind engine + relies on the presence of the NOTIFY signal in the Q_PROPERTY declaration + on a class to alert it that a property's value has changed. If this is omitted, the bind expression can still access the property's value, but - the expression will not be updated if the value changes. The following is + the expression will not be updated if the value changes. The following is an example of a QML friendly property declaration. \code @@ -356,20 +356,20 @@ }; \endcode - While generally no changes are needed to a C++ class to use property + While generally no changes are needed to a C++ class to use property binding, sometimes more advanced interaction between the binding engine and an object is desirable. To facilitate this, there is a special exception in the bind engine for allowing an object to access the binding directly. - If a binding is assigned to a property with a type of QmlBindableValue + If a binding is assigned to a property with a type of QmlBindableValue pointer (ie. QmlBindableValue *), each time the binding value changes, - a QmlBindableValue instance is assigned to that property. The + a QmlBindableValue instance is assigned to that property. The QmlBindableValue instance allows the object to read the binding and to evaluate the binding's current value. \section1 Signal Properties - In addition to reading and writing regular properties, QML allows you to + In addition to reading and writing regular properties, QML allows you to easily associate ECMAScript with signals. Consider the following example, in which Button is a made-up type with a clicked() signal. @@ -385,7 +385,7 @@ Like properties, signals automatically become available in QML without any additional work. As illustrated signals are mapped into QML as special - "signal properties", using the name "on" where the first + "signal properties", using the name "on" where the first character of the signal's name is uppercased. If more than one signal of the same name is exist on a class, only the first is available (see the \l Connection element for more general signal connections). @@ -393,11 +393,11 @@ An important observation to make here is the lack of braces. While both property bindings and signal properties involve executing ECMAScript code, property bindings dynamically update the property value (hence the braces), - whereas with signal properties the constant script "value" is actually - assigned to the signal property. Trying to bind a value to a signal + whereas with signal properties the constant script "value" is actually + assigned to the signal property. Trying to bind a value to a signal property will not work! - Signal parameters are also available to the executing script, as shown + Signal parameters are also available to the executing script, as shown below, as long as you remember to name the parameters of your signal in C++ (see QMetaMethod::parameterNames()). @@ -405,7 +405,7 @@ \row \o \code Example { - onDoSomething: for(var ii = 0; ii < count; ++ii) + onDoSomething: for(var ii = 0; ii < count; ++ii) print(message) } \endcode @@ -419,10 +419,10 @@ }; \endcode \endtable - + Just like property bindings, signal scripts are executed in a context. The signal script context is identical in scope to the "object context" under - property binding, with the exception that it has the signal parameters + property binding, with the exception that it has the signal parameters bound in. In addition to scripts, it is possible to assign objects to signal properties. @@ -439,9 +439,9 @@ \code Button { - id: MyButton + id: myButton onClicked: NumberAnimation { - target: MyButton + target: myButton property: "x" to: 100 } @@ -449,14 +449,14 @@ \endcode If the class itself actually defines a property called "on", this will - be assigned the string value and the signal handling behaviour will be + be assigned the string value and the signal handling behaviour will be disabled. \section1 Attached Properties Attached properties allow unrelated types to annotate another type with some additional properties. Some APIs or operations are inherintly imperative, - and attached properties help out when translating these APIs into the + and attached properties help out when translating these APIs into the declarative QML language. Qt's QGridLayout is one such example. @@ -484,7 +484,7 @@ } } \endcode - + Attached properties are identified by the use of a type name, in the case shown \c QGridLayout, as a grouped property specifier. To prevent ambiguity with actual class instantiations, attached properties must @@ -508,17 +508,17 @@ }; \endcode \endtable - + When an attached property is accessed, the QML engine will call this method to create an attachment object, passing in the object instance that the attached property applies to. The attachment object should define all the attached properties, and is generally parented to the provided object instance to avoid memory leaks. The QML engine does not saves this object, - so it is not necessary for the attached property function to ensure that + so it is not necessary for the attached property function to ensure that multiple calls for the same instance object return the same attached object. While conceptually simple, implementing an attachment object is not quite - so easy. The \c qmlAttachedProperties function is static - attachment + so easy. The \c qmlAttachedProperties function is static - attachment objects are not associated with any particular instance. How the values of the attached properties apply to the behaviour they are controlling is entirely implementation dependent. An additional consequence of this is @@ -537,13 +537,13 @@ The property has no effect because the (made-up) FancyGridLayout type defines the meaning of the \c row attached property only to apply to its direct children. It - is possible that other types may have attached properties that affect + is possible that other types may have attached properties that affect objects that aren't their direct children. - Attached properties are an advanced feature that should be used with + Attached properties are an advanced feature that should be used with caution. - \note We may implement a convenience wrapper that makes using attached + \note We may implement a convenience wrapper that makes using attached properties easier for the common "attach to children" case. \section1 Property Value Sources @@ -562,11 +562,11 @@ \endcode Here the \c x property of the rectangle will be animated from 0 to 100. - To support this, the NumberAnimation class inherits the + To support this, the NumberAnimation class inherits the QmlPropertyValueSource class. If a type inherits this class and is assigned to a property for which type assignment would otherwise fail (ie. the property itself doesn't have a type of QmlPropertyValueSource *), the QML - engine will automatically set the property as the target of the value + engine will automatically set the property as the target of the value source. \section1 Parser Status @@ -575,13 +575,13 @@ the appropriate properties, signals and slots and off you go. The QML engine takes care of instantiating your classes and setting the properties and everything works fine. - + However, sometimes it is helpful to know a little more about the status of - the QML parser. For example, it might be beneficial from a performance - standpoint to delay initializing some data structures until all the + the QML parser. For example, it might be beneficial from a performance + standpoint to delay initializing some data structures until all the properties have been set. - To assist with this, the QML engine defines an interface class called + To assist with this, the QML engine defines an interface class called QmlParserStatus. The interface defines a number of virtual methods that are invoked at various stages of the component instantiation. To receive these notifications, all a class has to do is to inherit the interface, and @@ -602,32 +602,32 @@ \section1 Extended Type Definitions - QML requires that types have the appropriate properties and signals to + QML requires that types have the appropriate properties and signals to work well within the declarative environment. In the case of existing - types, it is sometimes necessary to add signals, properties or slots to a - target class to make it more QML friendly but the original type cannot be - modified. For these cases, the QML engine supports extended type + types, it is sometimes necessary to add signals, properties or slots to a + target class to make it more QML friendly but the original type cannot be + modified. For these cases, the QML engine supports extended type definitions. An extended type definition allows the programmer to supply an additional type - known as the extension type - when registering the target class - whose properties, signals and slots are transparently merged with the + whose properties, signals and slots are transparently merged with the original target class when used from within QML. An extension class is a regular QObject, with a constructor that takes a - QObject pointer. When needed (extension classes are delay created + QObject pointer. When needed (extension classes are delay created until the first extension attribute is accessed) the extension class is created and the target object is passed in as the parent. When an extension attribute on the original is accessed, the appropriate signal, property or slots on the extension object is used instead. - When an extended type is installed, the + When an extended type is installed, the \code #define QML_DEFINE_EXTENDED_TYPE(T,QmlName,ExtendedTypeName) \endcode macro should be used instead of the regular \c QML_DEFINE_TYPE. - This example shows the addition of a read-only \c textLength property to + This example shows the addition of a read-only \c textLength property to QLabel being implemented as an extension. \table @@ -640,20 +640,20 @@ Q_PROPERTY(int textLength READ textLength) public: QWidgetExtension(QObject *parent) : QObject(parent) {} - int textLength() const { - return static_cast(parent())->text().count(); + int textLength() const { + return static_cast(parent())->text().count(); } }; QML_DEFINE_EXTENDED_TYPE(QLabel,QLabel,QLabelExtension); \endcode - \o + \o \code - QLabel { - id: Label1 + QLabel { + id: label1 text: "Hello World!" } - QLabel { - text: "Label1 text length: " + Label1.textLength + QLabel { + text: "label1 text length: " + label1.textLength } \endcode \endtable diff --git a/doc/src/declarative/qmlformat.qdoc b/doc/src/declarative/qmlformat.qdoc index f16adca..43eff05 100644 --- a/doc/src/declarative/qmlformat.qdoc +++ b/doc/src/declarative/qmlformat.qdoc @@ -7,20 +7,20 @@ \section1 Overview QML is an extension to \l {http://www.ecma-international.org/publications/standards/Ecma-262.htm} -{ECMAScript}. QML adds a mechanism for declaratively building a tree of objects, improved -integration between ECMAScript and Qt's existing QObject based type system, and support for -transparently maintained property value bindings between ECMAScript expressions and QObject +{ECMAScript}. QML adds a mechanism for declaratively building a tree of objects, improved +integration between ECMAScript and Qt's existing QObject based type system, and support for +transparently maintained property value bindings between ECMAScript expressions and QObject properties. Much of a QML file consists of valid ECMAScript \e {Statement}s. Except where constraints imposed by ECMAScript, C++ or QObject prevented it, the syntactic extensions introduced by QML are designed -to look similar and fit well with existing ECMAScript syntax and concepts. +to look similar and fit well with existing ECMAScript syntax and concepts. \section1 QML engine -The \l {QmlEngine}{QML engine} executes a \l {QmlComponent}{QML document} in a -\l {QmlContext}{QML context} to produce a \l {QObject}{QML object}. A single QML -document may be executed in one or many contexts to produce many QML objects. A single +The \l {QmlEngine}{QML engine} executes a \l {QmlComponent}{QML document} in a +\l {QmlContext}{QML context} to produce a \l {QObject}{QML object}. A single QML +document may be executed in one or many contexts to produce many QML objects. A single QML document may be executed many times in the same context to produce many QML objects. The QML engine provides the environment in which QML documents, contexts and objects @@ -34,10 +34,10 @@ and existing context properties cannot be modified. \i \e {QML object} will no longer evaluate bindings or scripts. \endlist -A QML document is a block of QML source code. QML documents generally correspond to files stored +A QML document is a block of QML source code. QML documents generally correspond to files stored on a disk or network resource, but can be constructed directly from text data. Syntactically a QML -document is self contained; QML does \bold {not} have a preprocessor that modifies the document -before presentation to the compiler. Type references within a QML document are resolved based +document is self contained; QML does \bold {not} have a preprocessor that modifies the document +before presentation to the compiler. Type references within a QML document are resolved based exclusively on the import statements present in the document. A simple QML document looks like this: @@ -49,7 +49,7 @@ A simple QML document looks like this: import Qt 4.6 Rectangle { - id: MyRect + id: myRect width: 100; height: 100 color: background } @@ -57,40 +57,40 @@ Rectangle { \endtable To instantiate a QML object, a QML document is executed in a QML context. QML contexts are used by -programmers to pass data to a QML document. QML documents may include property bindings or -ECMAScript blocks that can contain variable references that need to be resolved. Each property +programmers to pass data to a QML document. QML documents may include property bindings or +ECMAScript blocks that can contain variable references that need to be resolved. Each property binding and ECMAScript block has an associated QML context that is used to resolve these references that is determined by the QML context in which the document is executed. The example document above -contains one variable reference, \c background. +contains one variable reference, \c background. Each QML context defines a scope for variable resolution and each may define local, named context -properties. A QML context may also have a \l {QmlContext::addDefaultObject()}{default object}, -which is an object whose properties are searched \e after the context properties when resolving a -variable name. QML contexts form a tree, starting from a root context that is provided by the QML +properties. A QML context may also have a \l {QmlContext::addDefaultObject()}{default object}, +which is an object whose properties are searched \e after the context properties when resolving a +variable name. QML contexts form a tree, starting from a root context that is provided by the QML engine. When resolving variable references, the QML contexts are searched starting from the QML objects containing context upwards towards the root context. -Consider the following QML context tree. If the example QML document is executed in \c Context1, -the \c background variable will resolve to \c Context1's context property. If the document is -executed in \c Context2, the \c background variable will resolve to the root context's context +Consider the following QML context tree. If the example QML document is executed in \c Context1, +the \c background variable will resolve to \c Context1's context property. If the document is +executed in \c Context2, the \c background variable will resolve to the root context's context property. \image qml-context-tree.png While QML contexts can be created explicitly by the programmer to pass data into QML objects, the QML engine also creates a new implicit QML context for every object it instantiates. -Property bindings and ECMAScript blocks in the document are associated with this QML engine -created context. Object ids that are defined in the document are added as context properties, and +Property bindings and ECMAScript blocks in the document are associated with this QML engine +created context. Object ids that are defined in the document are added as context properties, and their value is set to reference the appropriate object, and the instantiated QML object is set as -the context's default object. The following diagram shows the result of executing a simple QML +the context's default object. The following diagram shows the result of executing a simple QML document. \image qml-context-object.png -The blue rectangle in the diagram represents a property binding. Associated with each property +The blue rectangle in the diagram represents a property binding. Associated with each property binding is the QML context to which it belongs, the object property to which it is bound and a -\e {scope object}. The scope object is usually, but not always, the object to which the bound -property belongs. The context properties, context default objects and the scope object are all +\e {scope object}. The scope object is usually, but not always, the object to which the bound +property belongs. The context properties, context default objects and the scope object are all involved when resolving a variable name in a binding. The following pseudo code describes the algorithm used: @@ -112,14 +112,14 @@ foreach (context in contextChain) { \endtable QML supports two categories of types: \e builtin types and \e composite types. Builtin types are -those written in C++ and registered with the QML engine. Builtin types form the most basic -building blocks of QML. Composite types are constructed by composing other builtin or composite -types, property bindings and ECMAScript blocks together into a brand new type using the QML +those written in C++ and registered with the QML engine. Builtin types form the most basic +building blocks of QML. Composite types are constructed by composing other builtin or composite +types, property bindings and ECMAScript blocks together into a brand new type using the QML language. Using a composite type is identical to using a builtin type. -For example, Qt 4.6 includes a builtin type called \c Image that shows a bitmap image. The +For example, Qt 4.6 includes a builtin type called \c Image that shows a bitmap image. The \c Image type has \c width and \c height properties that control the size of the displayed image. -A simple composite type, that will be called \c SquareImage can be built that adds a \c size +A simple composite type, that will be called \c SquareImage can be built that adds a \c size property that sets both the width and the height. \table @@ -129,22 +129,22 @@ property that sets both the width and the height. import Qt 4.6 Image { property int size - width: size - height: size + width: size + height: size } \endcode \endtable To the QML engine, a composite type is just another QML document. When a composite type is used the engine instantiates it just as it would any other document - by creating a new implicit -QML context and the object tree described by the document. The diagram below shows the +QML context and the object tree described by the document. The diagram below shows the \c SquareImage composite type used from within another QML document. When instantiated, the \c SquareImage object is created in its own QML context. Any property bindings specified in the \c SquareImage composite type document are associated with this context. Property bindings created in the outer document, however, are associated with its context, even those that are applied to the created \c SquareImage object. That is, the \c size, \c source, \c width and \c height property bindings all share a common \e {scope object}, but are owned by two different QML contexts. The -difference in containing context results in the \c Root variable resolving differently in the +difference in containing context results in the \c Root variable resolving differently in the different property bindings. \image qml-context.png @@ -173,7 +173,7 @@ The commenting rules in QML are the same as for ECMAScript. Both \e {MultiLineC \e {QMLImportStatement} \bold {:} \quotation -\bold {import} \e {StringLiteral} +\bold {import} \e {StringLiteral} \bold {import} \e {StringLiteral} \e {QMLVersionNumber} @@ -198,8 +198,8 @@ The commenting rules in QML are the same as for ECMAScript. Both \e {MultiLineC \section3 Semantics -The \e {QMLImportList} is used to statically resolve type references used within the enclosing -QML document. +The \e {QMLImportList} is used to statically resolve type references used within the enclosing +QML document. An import statement is used to bring a set of types into scope for a QML document. diff --git a/doc/src/declarative/qmlintro.qdoc b/doc/src/declarative/qmlintro.qdoc index ef84b8e..cfefdb9 100644 --- a/doc/src/declarative/qmlintro.qdoc +++ b/doc/src/declarative/qmlintro.qdoc @@ -80,11 +80,11 @@ expression has been assigned to is automatically updated to that value. \code Item { Text { - id: Text1 + id: text1 text: "Hello World" } Text { - id: Text2 + id: text2 text: Text1.text } } @@ -138,7 +138,7 @@ real, bool, string, color, and lists. Item { x: 10.5 // a 'real' property ... - state: "Details" // a 'string' property + state: "details" // a 'string' property focus: true // a 'bool' property } \endcode @@ -161,16 +161,16 @@ to refer to it elsewhere. \code Item { Text { - id: MyName + id: myName text: "..." } Text { - text: MyName.text + text: myName.text } } \endcode -\c ids must begin with a letter. We recommend that you start your ids with a capital letter. +\c Ids must begin with a lowercase letter. \section2 List properties -- cgit v0.12 From 8a54ed9524befc4a172cdc19a18d9953f3a01df0 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Wed, 7 Oct 2009 18:22:46 +1000 Subject: typos --- doc/src/declarative/advtutorial1.qdoc | 2 +- doc/src/declarative/advtutorial2.qdoc | 2 +- doc/src/declarative/advtutorial3.qdoc | 8 ++++---- doc/src/declarative/advtutorial4.qdoc | 6 +++--- doc/src/declarative/tutorial1.qdoc | 2 +- doc/src/declarative/tutorial2.qdoc | 2 +- doc/src/declarative/tutorial3.qdoc | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/doc/src/declarative/advtutorial1.qdoc b/doc/src/declarative/advtutorial1.qdoc index 48b32cd..f9c1f93 100644 --- a/doc/src/declarative/advtutorial1.qdoc +++ b/doc/src/declarative/advtutorial1.qdoc @@ -1,8 +1,8 @@ /*! \page advtutorial1.html \example declarative/tutorials/samegame/samegame1 -\title Advanced Tutorial 1 - Creating the Game canvas and block \target advtutorial1 +\title Advanced Tutorial 1 - Creating the Game canvas and block The first step is to create the items in your application. In Same Game we have a main game screen and the blocks that populate it. diff --git a/doc/src/declarative/advtutorial2.qdoc b/doc/src/declarative/advtutorial2.qdoc index 2d2fe19..4a6bb06 100644 --- a/doc/src/declarative/advtutorial2.qdoc +++ b/doc/src/declarative/advtutorial2.qdoc @@ -1,7 +1,7 @@ /*! \page advtutorial2.html -\title Advanced Tutorial 2 - Populating the Game Canvas \target advtutorial2 +\title Advanced Tutorial 2 - Populating the Game Canvas Now that we've written some basic elements, let's start writing the game. The first thing to do is to generate all of the blocks. Now we need to dynamically diff --git a/doc/src/declarative/advtutorial3.qdoc b/doc/src/declarative/advtutorial3.qdoc index 635054b..ffdc960 100644 --- a/doc/src/declarative/advtutorial3.qdoc +++ b/doc/src/declarative/advtutorial3.qdoc @@ -1,9 +1,9 @@ /*! \page advtutorial3.html -\title Advanced Tutorial 3 - Implementing the Game Logic \target advtutorial3 +\title Advanced Tutorial 3 - Implementing the Game Logic -To the initBoard function we added clearing the board before hand, so that clicking new game won't leave the previous game lying around in the background. To the createComponent function we have added setting the type of the block to a number between one and three - it's fundamental to the game logic that the blocks be different types if you want a fun game. +To the initBoard function we added clearing the board beforehand, so that clicking new game won't leave the previous game lying around in the background. To the createComponent function we have added setting the type of the block to a number between one and three - it's fundamental to the game logic that the blocks be different types if you want a fun game. The main change was adding the following game logic functions: \list @@ -23,9 +23,9 @@ You'll notice them referring to the 'gameCanvas' item. This is an item that has \snippet declarative/tutorials/samegame/samegame3/samegame.qml 1 -This item is the exact size of the board, contains a score property, and a mouse region for input. The blocks are now created as its children, and its size is used as the noe determining board size. Since it needs to bind its size to a multiple of tileSize, tileSize needs to be moved into a QML property and out of the script file. It can still be accessed from the script. +This item is the exact size of the board, contains a score property, and a mouse region for input. The blocks are now created as its children, and its size is used to determining the board size. Since it needs to bind its size to a multiple of tileSize, tileSize needs to be moved into a QML property and out of the script file. It can still be accessed from the script. -The mouse region simply calls handleClick(), which deals with the input events.Should those events cause the player to score, gameCanvas.score is updated. The score display text item has also been changed to bind its text property to gamecanvas.score. Note that if score was a global variable in the samegame.js file yo ucould not bind to it. You can only bind to QML properties. +The mouse region simply calls handleClick(), which deals with the input events. Should those events cause the player to score, gameCanvas.score is updated. The score display text item has also been changed to bind its text property to gamecanvas.score. Note that if score was a global variable in the samegame.js file you could not bind to it. You can only bind to QML properties. victoryCheck() mostly just updates score. But it also pops up a dialog saying 'Game Over' when the game is over. In this example we wanted a pure-QML, animated dialog, and since the Fx primitives set doesn't contain one, we wrote our own. Below is the code for the Dialog element, note how it's designed so as to be quite usable imperatively from within the script file: diff --git a/doc/src/declarative/advtutorial4.qdoc b/doc/src/declarative/advtutorial4.qdoc index 291d2f2..ae38c5e 100644 --- a/doc/src/declarative/advtutorial4.qdoc +++ b/doc/src/declarative/advtutorial4.qdoc @@ -1,7 +1,7 @@ /*! \page advtutorial4.html -\title Advanced Tutorial 4 - Finishing Touches \target advtutorial4 +\title Advanced Tutorial 4 - Finishing Touches Now we're going to do two things to liven the game up. Animate the blocks and add a web-based high score system. @@ -9,7 +9,7 @@ If you compare the samegame3 directory with samegame4, you'll noticed that we've \section2 Animated Blocks -The most vital animations are that the blocks move fluidly around the board. QML has many tools for fluid behavior, and in this case we're going to use the Follow element. By having the script set targetX and targetY, instead of x and y directly, we can set the x and y of the block to a follow. SpringFollow is a property value source, which means that you can set a property to be one of these elements and it will automatically bind the property to the element's value. The SpringFollow's value follows another value over time, when the value it is tracking changes the SpringFollow's value will also change, but it will move smoothly there over time with a spring-like movement (based on the spring parameters specified). This is shown in the below snippet of code from Block.qml: +The most vital animations are that the blocks move fluidly around the board. QML has many tools for fluid behavior, and in this case we're going to use the SpringFollow element. By having the script set targetX and targetY, instead of x and y directly, we can set the x and y of the block to a follow. SpringFollow is a property value source, which means that you can set a property to be one of these elements and it will automatically bind the property to the element's value. The SpringFollow's value follows another value over time, when the value it is tracking changes the SpringFollow's value will also change, but it will move smoothly there over time with a spring-like movement (based on the spring parameters specified). This is shown in the below snippet of code from Block.qml: \code property int targetX: 0 @@ -19,7 +19,7 @@ The most vital animations are that the blocks move fluidly around the board. QML y: SpringFollow { source: targetY; spring: 2; damping: 0.2 } \endcode -We also have to change the samegame.js code, so that wherever it was setting the x or y it now sets targetX and targetY (including when creating the block). This simple change is all you need to get spring moving blocks that no longer teleport around the board. If you try doing just this though, you'll notice that they now never jump from one point to another, even in the initialization! This gives an odd effect of having them all jump out of the corner (0,0) on start up. We'd rather that they fall down from the top in rows. To do this, we disable the x Follow (but not the y follow) and only enable it after we've set the x in the createBlock function. The above snippet now becomes: +We also have to change the samegame.js code, so that wherever it was setting the x or y it now sets targetX and targetY (including when creating the block). This simple change is all you need to get spring moving blocks that no longer teleport around the board. If you try doing just this though, you'll notice that they now never jump from one point to another, even in the initialization! This gives an odd effect of having them all jump out of the corner (0,0) on start up. We'd rather that they fall down from the top in rows. To do this, we disable the x follow (but not the y follow) and only enable it after we've set the x in the createBlock function. The above snippet now becomes: \snippet declarative/tutorials/samegame/samegame4/content/BoomBlock.qml 1 diff --git a/doc/src/declarative/tutorial1.qdoc b/doc/src/declarative/tutorial1.qdoc index d4f1095..e6232af 100644 --- a/doc/src/declarative/tutorial1.qdoc +++ b/doc/src/declarative/tutorial1.qdoc @@ -1,7 +1,7 @@ /*! \page tutorial1.html -\title Tutorial 1 - Hello World! \target tutorial1 +\title Tutorial 1 - Hello World! This first program is a simple "Hello world" example. The picture below is a screenshot of this program. diff --git a/doc/src/declarative/tutorial2.qdoc b/doc/src/declarative/tutorial2.qdoc index c6fd06b..c97fddf 100644 --- a/doc/src/declarative/tutorial2.qdoc +++ b/doc/src/declarative/tutorial2.qdoc @@ -1,7 +1,7 @@ /*! \page tutorial2.html -\title Tutorial 2 - Some colors \target tutorial2 +\title Tutorial 2 - Some colors This chapter adds a color picker to change the color of the text. diff --git a/doc/src/declarative/tutorial3.qdoc b/doc/src/declarative/tutorial3.qdoc index a0d842c..bce7e92 100644 --- a/doc/src/declarative/tutorial3.qdoc +++ b/doc/src/declarative/tutorial3.qdoc @@ -1,7 +1,7 @@ /*! \page tutorial3.html -\title Tutorial 3 - States \target tutorial3 +\title Tutorial 3 - States In this chapter, we make this example a little bit more dynamic by introducing states. -- cgit v0.12 From dd2f8a3224abff4f6528a23c821c44cbbf282073 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 8 Oct 2009 10:02:46 +1000 Subject: Font-portable. --- .../declarative/visual/easing/data/easing.0.png | Bin 20526 -> 3395 bytes .../declarative/visual/easing/data/easing.1.png | Bin 20526 -> 3379 bytes .../declarative/visual/easing/data/easing.2.png | Bin 20526 -> 3101 bytes .../declarative/visual/easing/data/easing.3.png | Bin 0 -> 16542 bytes .../auto/declarative/visual/easing/data/easing.qml | 498 +++++++++------------ tests/auto/declarative/visual/easing/easing.qml | 23 +- 6 files changed, 220 insertions(+), 301 deletions(-) create mode 100644 tests/auto/declarative/visual/easing/data/easing.3.png diff --git a/tests/auto/declarative/visual/easing/data/easing.0.png b/tests/auto/declarative/visual/easing/data/easing.0.png index fa078ae..2f1b5f6 100644 Binary files a/tests/auto/declarative/visual/easing/data/easing.0.png and b/tests/auto/declarative/visual/easing/data/easing.0.png differ diff --git a/tests/auto/declarative/visual/easing/data/easing.1.png b/tests/auto/declarative/visual/easing/data/easing.1.png index fa078ae..59083bd 100644 Binary files a/tests/auto/declarative/visual/easing/data/easing.1.png and b/tests/auto/declarative/visual/easing/data/easing.1.png differ diff --git a/tests/auto/declarative/visual/easing/data/easing.2.png b/tests/auto/declarative/visual/easing/data/easing.2.png index fa078ae..20c73c8 100644 Binary files a/tests/auto/declarative/visual/easing/data/easing.2.png and b/tests/auto/declarative/visual/easing/data/easing.2.png differ diff --git a/tests/auto/declarative/visual/easing/data/easing.3.png b/tests/auto/declarative/visual/easing/data/easing.3.png new file mode 100644 index 0000000..c68e0fa Binary files /dev/null and b/tests/auto/declarative/visual/easing/data/easing.3.png differ diff --git a/tests/auto/declarative/visual/easing/data/easing.qml b/tests/auto/declarative/visual/easing/data/easing.qml index c41d676..d5beeef 100644 --- a/tests/auto/declarative/visual/easing/data/easing.qml +++ b/tests/auto/declarative/visual/easing/data/easing.qml @@ -6,862 +6,774 @@ VisualTest { } Frame { msec: 16 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 32 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 48 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 64 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 80 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 96 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 112 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 128 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 144 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 160 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 176 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 192 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 208 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 224 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 240 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 256 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 272 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" + } + Mouse { + type: 2 + button: 1 + buttons: 1 + x: 111; y: 419 + modifiers: 0 + sendToViewport: true } Frame { msec: 288 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 304 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 320 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "8f4c40d2e2b4f064bcb77c5ae43928c6" } Frame { msec: 336 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "8b65094a9b7d5394fc67f92ea058627f" } Frame { msec: 352 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "da450826b471a60ba98dabc581631ba1" } Frame { msec: 368 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "e820fb4f1bc97152aa940b07db549f1b" } Frame { msec: 384 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "b7d8186beca2fa0e37099f72419350f4" } Frame { msec: 400 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "8500b93774f214e5e4789e25500262b8" } Frame { msec: 416 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "277e1dff70285cca536b3e1fc2590688" } Frame { msec: 432 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "b05b18f92c2089c681661566117ae0f5" } Frame { msec: 448 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "6fec9c6b6ac3e3ea4126e3824a8d7566" } Frame { msec: 464 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "53c6c90dd1eb7ca47721fc116474aebf" } Frame { msec: 480 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "cf729c4a31414af3d2705878ba615738" } Frame { msec: 496 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" - } - Mouse { - type: 2 - button: 1 - buttons: 1 - x: 293; y: 405 - modifiers: 0 - sendToViewport: true + hash: "f146b8a68960d507f893ef001189220e" } Frame { msec: 512 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "18ff56b870bb048af246f928ee42a9b0" } Frame { msec: 528 - hash: "b7f8cf8b426db83a5a4cc1f673650842" + hash: "beee98f73fe7e878ada37b3070fa0c1d" } Frame { msec: 544 - hash: "f9a41aaf57b18271d467b73e609c8a28" + hash: "435d389082912950a0be2b5dff480319" } Frame { msec: 560 - hash: "2607ceafe74863a4810fc11754be7745" + hash: "dc39b080eaddeaf4e309b90b7d97a835" } Frame { msec: 576 - hash: "c80df114e67af7c9c4d61917938bba60" - } - Mouse { - type: 3 - button: 1 - buttons: 0 - x: 293; y: 405 - modifiers: 0 - sendToViewport: true + hash: "666b1cde53f78d7db9c81e21adbe406a" } Frame { msec: 592 - hash: "c80df114e67af7c9c4d61917938bba60" + hash: "c5c9627f4329e48aa96ebfbc982b6ba6" } Frame { msec: 608 - hash: "c80df114e67af7c9c4d61917938bba60" + hash: "a583042052e5da7e80a4956337d6d1ff" } Frame { msec: 624 - hash: "21fb97b78a419db73303a01ae99820ea" + hash: "a4a5df787e15da6f28275a12898e7620" } Frame { msec: 640 - hash: "2b3878b2698798e94a9fcf429be908d0" + hash: "02cacec2ccc803ebc03c5540484cbcaa" } Frame { msec: 656 - hash: "78ce8b817edec30801720203b01eefa8" + hash: "00600df1f006f358feaf43bfae9d32a5" } Frame { msec: 672 - hash: "2560e4300b06cf33dcd58880ddb298f3" + hash: "737c884ba0d6d38b66252f4b97a36c33" } Frame { msec: 688 - hash: "2a25abaa2b0ce9b5b39b2fa04ef4c77d" + hash: "7eeeade8100c84a6b56efa51cf597baf" } Frame { msec: 704 - hash: "52bd37c4dc3ba8ebf8152b0f1e35e4b0" + hash: "18ab79d495097f0103dcf14db1897a88" } Frame { msec: 720 - hash: "6921eb51b6d967980adc28d964d5a88f" + hash: "21d3b0da00c46a101e09048928cd8027" } Frame { msec: 736 - hash: "b6d8f7879a170a0311a3f4689388dd40" + hash: "a5995b0341872c275ffbc5aaee6eb853" } Frame { msec: 752 - hash: "7ebefa6c5ce5dd18d3df566fd9f396fe" + hash: "bb4a37c1bd5e412ebce54d9539017723" } Frame { msec: 768 - hash: "8c097cf34a1af48e336581c01f166978" + hash: "63dcde9e2751ca94ed7d739feb359221" } Frame { msec: 784 - hash: "2a28843361f763ba83b02a0c8ef5094b" + hash: "5790c8407e2e4d1a6a937d86d57d8edb" } Frame { msec: 800 - hash: "07d699dc6dc9e3013a83dff04ae0956e" + hash: "3a1c77abf6822030db60a036027dc86e" } Frame { msec: 816 - hash: "09935d52bf4602cbdc06c6e5e755bc64" + hash: "2a13c573ab9846cce60384dd7138b2b4" } Frame { msec: 832 - hash: "fcad934f3cf4f542ab8cd70ef3915e44" + hash: "98983c2525265830033495b61071a5aa" } Frame { msec: 848 - hash: "602bfdd9831ef1facb42e031c545749f" + hash: "26d2bba3d77053b410715afb497d4063" } Frame { msec: 864 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "fd65d954c16acee425d9de65af68ef40" } Frame { msec: 880 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "094fcc18d28b19ac6b452dd8106d813b" } Frame { msec: 896 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "160105f6f99a960763535e4d51990ef6" } Frame { msec: 912 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "0d5d1e6a66fc1f49f1106f01fb5a1c52" } Frame { msec: 928 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "f6abc32680865783a4d94ecb738f9ff6" } Frame { msec: 944 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "350509eceb134d5b18647e5ad07dbb47" } Frame { msec: 960 - image: "easing.0.png" + image: "/home/wallison/qt/kinetic/tests/auto/declarative/visual/easing/data/easing.0.png" } Frame { msec: 976 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "4c9de74276d32c5b2787cf75e612f97d" } Frame { msec: 992 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "efcc5ae79da3fa2f4c7d6eaa35e32d33" } Frame { msec: 1008 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "ff4afce604c8ecb4f08d1ddef8552534" } Frame { msec: 1024 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "e2e63e12e9a5f8459720dd8b023ed17b" } Frame { msec: 1040 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "991a01f92bcfa9cd9fe98e3f39d192fc" } Frame { msec: 1056 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bc3d2f0f3fac650c981457f3694c2518" } Frame { msec: 1072 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "ee39fc9b1a602bf813d9118aa21901ac" } Frame { msec: 1088 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "42120d098f2adf1e331332b33442dd3e" } Frame { msec: 1104 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "1660c69b77b800d1ab57b93f0fc12aa5" } Frame { msec: 1120 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "0630a3d6b8cb5dece5dc660f05036ec6" } Frame { msec: 1136 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "9163f0bd9c5888794d7a09d3359bf1e5" } Frame { msec: 1152 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "e0b7ad4883f679948c852ff152ba7907" } Frame { msec: 1168 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "f748fc44f99b706e42b899cb18dbaaf7" } Frame { msec: 1184 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "c84442f0cb1cf0bb50dae7d1c701aaf8" } Frame { msec: 1200 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "d7b41567e3f3aa9576fe2793872134b7" } Frame { msec: 1216 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "a1d10ff1adb85000902486fc8e4faa8d" } Frame { msec: 1232 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "44b7b5d77068e360ead3af84e7d80232" } Frame { msec: 1248 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "486c0b19c1379d9eefdf575a085e2875" } Frame { msec: 1264 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "1d474472856d4740d960eb2f788ca5a6" } Frame { msec: 1280 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "c74082553ab0f4ee00f5044e3369580b" } Frame { msec: 1296 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "89fcd5514f336075ad32cae69518c1e5" } Frame { msec: 1312 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "9dd235eb98998d9bdd92e01300297257" } Frame { msec: 1328 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "9dd235eb98998d9bdd92e01300297257" } Frame { msec: 1344 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "9dd235eb98998d9bdd92e01300297257" } Frame { msec: 1360 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "9dd235eb98998d9bdd92e01300297257" } Frame { msec: 1376 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "9dd235eb98998d9bdd92e01300297257" } Frame { msec: 1392 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" - } - Mouse { - type: 2 - button: 1 - buttons: 1 - x: 293; y: 405 - modifiers: 0 - sendToViewport: true + hash: "9dd235eb98998d9bdd92e01300297257" } Frame { msec: 1408 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "9dd235eb98998d9bdd92e01300297257" } Frame { msec: 1424 - hash: "b7f8cf8b426db83a5a4cc1f673650842" + hash: "9dd235eb98998d9bdd92e01300297257" } Frame { msec: 1440 - hash: "f9a41aaf57b18271d467b73e609c8a28" - } - Mouse { - type: 3 - button: 1 - buttons: 0 - x: 293; y: 405 - modifiers: 0 - sendToViewport: true + hash: "9dd235eb98998d9bdd92e01300297257" } Frame { msec: 1456 - hash: "f9a41aaf57b18271d467b73e609c8a28" + hash: "9dd235eb98998d9bdd92e01300297257" } Frame { msec: 1472 - hash: "f9a41aaf57b18271d467b73e609c8a28" + hash: "9dd235eb98998d9bdd92e01300297257" } Frame { msec: 1488 - hash: "6837618bfafa541897d1f749de527ef0" + hash: "9dd235eb98998d9bdd92e01300297257" } Frame { msec: 1504 - hash: "c50ce6e3c3a212d2ffdb72a1d3588f42" + hash: "9dd235eb98998d9bdd92e01300297257" } Frame { msec: 1520 - hash: "33c6a60e9e82a01055202dd937db2770" + hash: "9dd235eb98998d9bdd92e01300297257" } Frame { msec: 1536 - hash: "c8d2e502901da8f44eaf9684e1a4adea" + hash: "9dd235eb98998d9bdd92e01300297257" } Frame { msec: 1552 - hash: "d51c5f7c9bac986a9c2ce7323a69f864" + hash: "9dd235eb98998d9bdd92e01300297257" } Frame { msec: 1568 - hash: "687214f92a4cc60c5208a59a7824e30e" + hash: "9dd235eb98998d9bdd92e01300297257" } Frame { msec: 1584 - hash: "7fe974f28880037ec592c0525468248a" + hash: "9dd235eb98998d9bdd92e01300297257" } Frame { msec: 1600 - hash: "c7aa4f0ffbc0b5e231cce0c75dec7a97" + hash: "9dd235eb98998d9bdd92e01300297257" + } + Mouse { + type: 3 + button: 1 + buttons: 0 + x: 111; y: 419 + modifiers: 0 + sendToViewport: true } Frame { msec: 1616 - hash: "7000e685420a3fbf1d3d7d22b745c58f" + hash: "9dd235eb98998d9bdd92e01300297257" } Frame { msec: 1632 - hash: "3f85aa08cf725234319ab01ff16b4bff" + hash: "9dd235eb98998d9bdd92e01300297257" } Frame { msec: 1648 - hash: "326347eb8a01236464140bbcc84745a7" + hash: "b77240f32e83d4f332d815c626f1e560" } Frame { msec: 1664 - hash: "e0fed8a1bc453b09df05ff9a5326b38a" + hash: "7d89669231224cf8e02d75338c37c278" } Frame { msec: 1680 - hash: "a81d7fb7673449a38579baf879313b63" + hash: "a8cf7c179011ee8187a8e1111683e52e" } Frame { msec: 1696 - hash: "69235e99941bf5d6c50fbe6dbbda5945" + hash: "3e87a57e05da09a8260801320431b922" } Frame { msec: 1712 - hash: "346e107de2853c5b1ba74411ceafaf8d" + hash: "a2b0d99c8a232715fe03e8772a36634c" } Frame { msec: 1728 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "5b4634cd495ae7bb9c69a5c9c346189e" } Frame { msec: 1744 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "492f8f2b84af355ef41c1a7cda3a8a73" } Frame { msec: 1760 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "88e4eb08520fb5acc3d88ac4f0900542" } Frame { msec: 1776 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "0c09cdcb906b4ce9840fd7502c39e5b9" } Frame { msec: 1792 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "b054083bdd212cc03167a90df2d7eac5" } Frame { msec: 1808 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "83971c2d37616ab92680364d6ac288a6" } Frame { msec: 1824 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "a73951d25e2cb7c1d04c88c86dfa0e4d" } Frame { msec: 1840 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "31fc8b20302abac97e506c37a14bbb7e" } Frame { msec: 1856 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "f760ccd7339e01a9423da7b592498291" } Frame { msec: 1872 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "24dfcd5553f854908396de751fb15b88" } Frame { msec: 1888 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "1daf38a6e6199f980e9494a3eb480047" } Frame { msec: 1904 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "a39e2de1090209e5dbc8cc26577ec97d" } Frame { msec: 1920 - image: "easing.1.png" + image: "/home/wallison/qt/kinetic/tests/auto/declarative/visual/easing/data/easing.1.png" } Frame { msec: 1936 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "2d2ce71a074f045916a207044abd055a" } Frame { msec: 1952 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "a19b0353604491f56f72be0d20d76955" } Frame { msec: 1968 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "9a70f109eebfcede2311ef77ceb50a44" } Frame { msec: 1984 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "7b28313d6860aeefd4a4e136d38d62f8" } Frame { msec: 2000 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "95d84f38473159fe6b38f84ffe371714" } Frame { msec: 2016 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "07f91261794edb0ac1fde9bb4ff36011" } Frame { msec: 2032 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "f9a4a6b92a9c2d265688f1bfac18fa0a" } Frame { msec: 2048 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "cdec7cc00380fde4f73be997a992251a" } Frame { msec: 2064 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "a52b34f84e98fcd8babb1d39979fc9c7" } Frame { msec: 2080 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bf05b3c79a9616f2e6c33d348b30e0ba" } Frame { msec: 2096 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "c5931785685b4f4854d3ddfff5dd5466" } Frame { msec: 2112 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" - } - Mouse { - type: 2 - button: 1 - buttons: 1 - x: 294; y: 405 - modifiers: 0 - sendToViewport: true + hash: "bae163e02b860a9ca19d1bcb60ac1f8e" } Frame { msec: 2128 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "a36295a1ebb35e538f8899ae3ae3b36a" } Frame { msec: 2144 - hash: "b7f8cf8b426db83a5a4cc1f673650842" + hash: "b6448d61803d9b2c05b438aa8ce8bcd5" } Frame { msec: 2160 - hash: "f9a41aaf57b18271d467b73e609c8a28" + hash: "631bf4caff2d93ef96a426100ffc5b32" } Frame { msec: 2176 - hash: "2607ceafe74863a4810fc11754be7745" + hash: "a8777c84a03996493f719f5fcfc80d00" } Frame { msec: 2192 - hash: "c80df114e67af7c9c4d61917938bba60" + hash: "86e1759df103ef776bb03f24941f49da" } Frame { msec: 2208 - hash: "b33f77efd04ccde252fefbf2d8a0cd60" - } - Mouse { - type: 3 - button: 1 - buttons: 0 - x: 294; y: 405 - modifiers: 0 - sendToViewport: true + hash: "01a790ea60adeaf368c66bd53aa8fcb3" } Frame { msec: 2224 - hash: "b33f77efd04ccde252fefbf2d8a0cd60" + hash: "79e5aca8ef6b9764f7f99cdfb51222ae" } Frame { msec: 2240 - hash: "b33f77efd04ccde252fefbf2d8a0cd60" + hash: "82d10cc01b9be4683c5aa76096bd462c" } Frame { msec: 2256 - hash: "fd993a41d312ccfdbd6206a4f33aaa5f" + hash: "95d961a92c597e432611947f7480796a" } Frame { msec: 2272 - hash: "27a704ddc65928d6c7732c14d357b796" + hash: "e8ee89b5313c7e2c66741fe1c2090029" } Frame { msec: 2288 - hash: "7f466d3d85a94178b2e9e06cee9cb35d" + hash: "2e3e8cf25dc1a3f09e7bf2a086f8e3bb" } Frame { msec: 2304 - hash: "2fc08efcc8e8daaf0b0f85bbca3b1b9e" + hash: "68ca8ad381f48db23d2bc5da9da0c17a" } Frame { msec: 2320 - hash: "8b4d5586c8ebf5654156251c46479c61" + hash: "e29f2411667049e8fae6c080f61c5869" } Frame { msec: 2336 - hash: "50cbc5513143056667645d5ea25aceab" + hash: "5b0a6fadedf3024e8ecb7f2c73a2277d" } Frame { msec: 2352 - hash: "2e59236e75e7cc97c25b6eb816c9a116" + hash: "af2eac625ef1fd928093ccd60bc0058e" } Frame { msec: 2368 - hash: "f865be9e69de683a150d3a43ae740c1b" + hash: "8a1ff780ebdc9e416e60ea0940e8f2d6" } Frame { msec: 2384 - hash: "816d3ed67a449dcaf71f5c82b07c0d7c" + hash: "7eb316c51cfd8ad972b7040247a651eb" } Frame { msec: 2400 - hash: "5271565364560bed69fddf75b1945a94" + hash: "1bac7075c10c87a69e71c3859f0db41d" } Frame { msec: 2416 - hash: "e89015974ae8e05ae524dc51f1724494" + hash: "0f16f40567729065cf9ecfcc15395a7b" } Frame { msec: 2432 - hash: "fd0b8d6d4540eeebc22c25f592fdcf77" + hash: "719f4e776776f0db5c68ae7c6177e9b7" } Frame { msec: 2448 - hash: "35348763f8d2fb13e1421e9f796f46a8" + hash: "75172dbf31fd8d706f54748c59099845" } Frame { msec: 2464 - hash: "6c73c47b5b3a9db6cd73c0167125774b" + hash: "d730b550e05167b05350e0e6636dd97d" } Frame { msec: 2480 - hash: "f3e947a709bb949eb9e31223aa83e696" + hash: "e1f33eb5f023d9d42a99f8bc23223c45" } Frame { msec: 2496 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "8a4b0df5bed6c7be73c194ce2bb6a271" } Frame { msec: 2512 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "44a9ea371f12d4ac3a569121a995ae16" } Frame { msec: 2528 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "14747e2e9e072210b9d6db50b4f704a1" } Frame { msec: 2544 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "eea52abf430f8cc1adc37e7180036584" } Frame { msec: 2560 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "0a9f6b14bc02e929a45bf4ebb736f9d3" } Frame { msec: 2576 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "a68a6eef0fc8754564c47c88b60d9a2a" } Frame { msec: 2592 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "eeb469e2fbda131d83538055e88ecdf7" } Frame { msec: 2608 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "0f7b673472050e807c9d935fde5afd83" } Frame { msec: 2624 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "80c90cce66bdd2324ca98bc591c22b44" } Frame { msec: 2640 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 2656 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 2672 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 2688 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 2704 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 2720 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 2736 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 2752 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 2768 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 2784 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 2800 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 2816 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 2832 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 2848 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 2864 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 2880 - image: "easing.2.png" + image: "/home/wallison/qt/kinetic/tests/auto/declarative/visual/easing/data/easing.2.png" } Frame { msec: 2896 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 2912 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 2928 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 2944 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 2960 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 2976 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 2992 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 3008 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } Frame { msec: 3024 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" - } - Frame { - msec: 3040 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" - } - Key { - type: 6 - key: 16777249 - modifiers: 67108864 - text: "" - autorep: false - count: 1 - } - Frame { - msec: 3056 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" - } - Frame { - msec: 3072 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" - } - Frame { - msec: 3088 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" - } - Frame { - msec: 3104 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" - } - Frame { - msec: 3120 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" - } - Frame { - msec: 3136 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" - } - Frame { - msec: 3152 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" - } - Frame { - msec: 3168 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" - } - Frame { - msec: 3184 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" - } - Frame { - msec: 3200 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" - } - Frame { - msec: 3216 - hash: "fb57b2d47ca82a5f1301aac14c8ff67e" + hash: "bb8e2ba14526dc5ad74f74e8ff3d96a5" } } diff --git a/tests/auto/declarative/visual/easing/easing.qml b/tests/auto/declarative/visual/easing/easing.qml index 1448064..f81400b 100644 --- a/tests/auto/declarative/visual/easing/easing.qml +++ b/tests/auto/declarative/visual/easing/easing.qml @@ -140,18 +140,24 @@ Rectangle { Repeater { model: easingtypes Component { - Text { - id: text - text: type + Rectangle { + id: block + Text { + text: type + anchors.centerIn: parent + font.italic: true + color: index & 1 ? "black" : "white" + opacity: 0 // 1 for debugging + } + width: 120 height: 18 - font.italic: true - color: "black" + color: index & 1 ? "red" : "blue" states: [ State { name: "from" when: !mouse.pressed PropertyChanges { - target: text + target: block x: 0 } }, @@ -159,8 +165,8 @@ Rectangle { name: "to" when: mouse.pressed PropertyChanges { - target: text - x: item.width-100 + target: block + x: item.width-block.width } } ] @@ -172,6 +178,7 @@ Rectangle { NumberAnimation { properties: "x" easing: type + duration: 1000 } } ] -- cgit v0.12 From 4cd7e2a0a956b1f9a0ea0d4691ebb1380ebc7c84 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Thu, 8 Oct 2009 10:40:05 +1000 Subject: doc cleanup --- doc/src/declarative/anchor-layout.qdoc | 2 +- doc/src/declarative/focus.qdoc | 2 +- doc/src/declarative/qmlintro.qdoc | 1 + doc/src/declarative/tutorial2.qdoc | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/src/declarative/anchor-layout.qdoc b/doc/src/declarative/anchor-layout.qdoc index e723d5c..8590aba 100644 --- a/doc/src/declarative/anchor-layout.qdoc +++ b/doc/src/declarative/anchor-layout.qdoc @@ -14,7 +14,7 @@ Rectangle { id: rect1; ... } Rectangle { id: rect2; anchors.left: rect1.right; ... } \endcode -In this case, the left edge of \e rect2 is bound to the right edge of rect1, producing the following: +In this case, the left edge of \e rect2 is bound to the right edge of \e rect1, producing the following: \image edge1.png diff --git a/doc/src/declarative/focus.qdoc b/doc/src/declarative/focus.qdoc index 1e00bd9..14bebb1 100644 --- a/doc/src/declarative/focus.qdoc +++ b/doc/src/declarative/focus.qdoc @@ -17,7 +17,7 @@ When the user presses or releases a key, the following occurs: \o The key event is delivered by the scene to the QML \l Item with \e {active focus}. If no \l Item has \e {active focus}, the key event is \l {QEvent::ignore()}{ignored} and regular Qt key handling continues. \o If the QML \l Item with \e {active focus} accepts the key event, propagation stops. Otherwise the event is "bubbled up", by recursively passing it to each \l Item's parent until either the event is accepted, or the root \l Item is reached. -If the \c {Rect} element in the following example has active focus and the \e A key is pressed, it will bubble up to the \c {KeyActions}. However, pressing the \e B key will bubble up to the root item and thus subsequently be \l {QEvent::ignore()}{ignored}. +If the \c {Rectangle} element in the following example has active focus and the \e A key is pressed, it will bubble up to the \c {KeyActions}. However, pressing the \e B key will bubble up to the root item and thus subsequently be \l {QEvent::ignore()}{ignored}. \code Item { diff --git a/doc/src/declarative/qmlintro.qdoc b/doc/src/declarative/qmlintro.qdoc index cfefdb9..56cc804 100644 --- a/doc/src/declarative/qmlintro.qdoc +++ b/doc/src/declarative/qmlintro.qdoc @@ -124,6 +124,7 @@ In the above example, the Text object will have normal opacity, since the line opacity: 0.5 has been turned into a comment. \section1 Properties +\target intro-properties \section2 Property naming diff --git a/doc/src/declarative/tutorial2.qdoc b/doc/src/declarative/tutorial2.qdoc index a076a62..66a0515 100644 --- a/doc/src/declarative/tutorial2.qdoc +++ b/doc/src/declarative/tutorial2.qdoc @@ -30,7 +30,7 @@ An \l Item is the most basic visual element in QML and is often used as a contai We declare a \c color property. This property is accessible from \e outside our component, this allows us to instantiate the cells with different colors. -This property is just an alias to an existing property - the color of the rectangle that compose the cell (see \l{Properties}). +This property is just an alias to an existing property - the color of the rectangle that compose the cell (see \l{intro-properties}{Properties}). \snippet examples/declarative/tutorials/helloworld/Cell.qml 5 -- cgit v0.12 From 72c3aefaa4c66d1cb6dcc99dadd808d921c9bfb7 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 8 Oct 2009 11:53:28 +1000 Subject: Rename preserveSelection to persistentSelection Task-number: QT-1113 --- src/declarative/QmlChanges.txt | 1 + src/declarative/fx/qfxtextedit.cpp | 14 +++++++------- src/declarative/fx/qfxtextedit.h | 6 +++--- src/declarative/fx/qfxtextedit_p.h | 4 ++-- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt index 7661e03..ee5acd4 100644 --- a/src/declarative/QmlChanges.txt +++ b/src/declarative/QmlChanges.txt @@ -41,6 +41,7 @@ Text elements: hAlign -> horizontalAlignment Text elements: vAlign -> verticalAlignment Text elements: highlightColor -> selectionColor Text elements: highlightedTextColor -> selectedTextColor +Text elements: preserveSelection -> persistentSelection State: operations -> changes Transition: operations -> animations Transition: fromState -> from diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp index f4c2e4c..07444bb 100644 --- a/src/declarative/fx/qfxtextedit.cpp +++ b/src/declarative/fx/qfxtextedit.cpp @@ -407,7 +407,7 @@ void QFxTextEdit::setCursorVisible(bool on) return; d->cursorVisible = on; QFocusEvent focusEvent(on ? QEvent::FocusIn : QEvent::FocusOut); - if (!on && !d->preserveSelection) + if (!on && !d->persistentSelection) d->control->setCursorIsFocusIndicator(true); d->control->processEvent(&focusEvent, QPointF(0, 0)); } @@ -590,23 +590,23 @@ void QFxTextEdit::setFocusOnPress(bool on) } /*! - \qmlproperty bool TextEdit::preserveSelection + \qmlproperty bool TextEdit::persistentSelection Whether the TextEdit should keep the selection visible when it loses focus to another item in the scene. By default this is set to true; */ -bool QFxTextEdit::preserveSelection() const +bool QFxTextEdit::persistentSelection() const { Q_D(const QFxTextEdit); - return d->preserveSelection; + return d->persistentSelection; } -void QFxTextEdit::setPreserveSelection(bool on) +void QFxTextEdit::setPersistentSelection(bool on) { Q_D(QFxTextEdit); - if (d->preserveSelection == on) + if (d->persistentSelection == on) return; - d->preserveSelection = on; + d->persistentSelection = on; } qreal QFxTextEdit::textMargin() const diff --git a/src/declarative/fx/qfxtextedit.h b/src/declarative/fx/qfxtextedit.h index 1a5d968..f4f101a 100644 --- a/src/declarative/fx/qfxtextedit.h +++ b/src/declarative/fx/qfxtextedit.h @@ -83,7 +83,7 @@ class Q_DECLARATIVE_EXPORT QFxTextEdit : public QFxPaintedItem Q_PROPERTY(int selectionEnd READ selectionEnd WRITE setSelectionEnd NOTIFY selectionEndChanged) Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectionChanged) Q_PROPERTY(bool focusOnPress READ focusOnPress WRITE setFocusOnPress) - Q_PROPERTY(bool preserveSelection READ preserveSelection WRITE setPreserveSelection) + Q_PROPERTY(bool persistentSelection READ persistentSelection WRITE setPersistentSelection) Q_PROPERTY(qreal textMargin READ textMargin WRITE setTextMargin) public: @@ -154,8 +154,8 @@ public: bool focusOnPress() const; void setFocusOnPress(bool on); - bool preserveSelection() const; - void setPreserveSelection(bool on); + bool persistentSelection() const; + void setPersistentSelection(bool on); qreal textMargin() const; void setTextMargin(qreal margin); diff --git a/src/declarative/fx/qfxtextedit_p.h b/src/declarative/fx/qfxtextedit_p.h index 9c73db9..82481ff 100644 --- a/src/declarative/fx/qfxtextedit_p.h +++ b/src/declarative/fx/qfxtextedit_p.h @@ -70,7 +70,7 @@ public: QFxTextEditPrivate() : color("black"), imgDirty(true), hAlign(QFxTextEdit::AlignLeft), vAlign(QFxTextEdit::AlignTop), dirty(false), wrap(false), richText(false), cursorVisible(false), focusOnPress(false), - preserveSelection(true), textMargin(0.0), lastSelectionStart(0), lastSelectionEnd(0), + persistentSelection(true), textMargin(0.0), lastSelectionStart(0), lastSelectionEnd(0), cursorComponent(0), cursor(0), format(QFxTextEdit::AutoText), document(0) { } @@ -98,7 +98,7 @@ public: bool richText; bool cursorVisible; bool focusOnPress; - bool preserveSelection; + bool persistentSelection; qreal textMargin; int lastSelectionStart; int lastSelectionEnd; -- cgit v0.12 From 75da89f26a89ac1224372277799051f9224dbbe7 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 8 Oct 2009 12:43:29 +1000 Subject: Allow dial to be built as an exe. --- examples/declarative/dial/dial.pro | 9 +++++++++ examples/declarative/dial/dial.qrc | 10 ++++++++++ examples/declarative/dial/main.cpp | 18 ++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 examples/declarative/dial/dial.pro create mode 100644 examples/declarative/dial/dial.qrc create mode 100644 examples/declarative/dial/main.cpp diff --git a/examples/declarative/dial/dial.pro b/examples/declarative/dial/dial.pro new file mode 100644 index 0000000..1d1f811 --- /dev/null +++ b/examples/declarative/dial/dial.pro @@ -0,0 +1,9 @@ +SOURCES = main.cpp +RESOURCES = dial.qrc + +QT += script declarative + +target.path = $$[QT_INSTALL_EXAMPLES]/declarative/dial +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS dial.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/dial +INSTALLS += target sources diff --git a/examples/declarative/dial/dial.qrc b/examples/declarative/dial/dial.qrc new file mode 100644 index 0000000..77354c0 --- /dev/null +++ b/examples/declarative/dial/dial.qrc @@ -0,0 +1,10 @@ + + + DialLibrary/background.png + DialLibrary/overlay.png + DialLibrary/needle_shadow.png + DialLibrary/needle.png + DialLibrary/Dial.qml + dial.qml + + diff --git a/examples/declarative/dial/main.cpp b/examples/declarative/dial/main.cpp new file mode 100644 index 0000000..b65c9ff --- /dev/null +++ b/examples/declarative/dial/main.cpp @@ -0,0 +1,18 @@ +#include +#include +#include + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + QmlView *canvas = new QmlView; + canvas->setUrl(QUrl("qrc:/dial.qml")); + canvas->execute(); + canvas->resize(210,240); + canvas->show(); + + return app.exec(); +} + + -- cgit v0.12 From 28c8570d38fe1a5f57300a48668506a6235a9081 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 8 Oct 2009 13:55:39 +1000 Subject: Fix relative-URLs of test scripts --- tools/qmlviewer/qfxtester.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/qmlviewer/qfxtester.cpp b/tools/qmlviewer/qfxtester.cpp index a6a46eb..87ab43b 100644 --- a/tools/qmlviewer/qfxtester.cpp +++ b/tools/qmlviewer/qfxtester.cpp @@ -140,7 +140,8 @@ void QFxTester::run() void QFxTester::save() { QString filename = m_script + QLatin1String(".qml"); - QDir saveDir = QFileInfo(filename).absoluteDir(); + QFileInfo filenameInfo(filename); + QDir saveDir = filenameInfo.absoluteDir(); saveDir.mkpath("."); QFile file(filename); @@ -160,7 +161,7 @@ void QFxTester::save() if (!fe.hash.isEmpty()) { ts << " hash: \"" << fe.hash.toHex() << "\"\n"; } else if (!fe.image.isNull()) { - QString filename = m_script + "." + QString::number(imgCount++) + ".png"; + QString filename = filenameInfo.baseName() + "." + QString::number(imgCount++) + ".png"; fe.image.save(filename); ts << " image: \"" << filename << "\"\n"; } -- cgit v0.12