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 5b77922f3782de4b96d6cf07ebb88419de130eac Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 7 Oct 2009 12:46:59 +1000 Subject: SameGame tutorial images --- doc/src/declarative/pics/declarative-adv-tutorial1.png | Bin 0 -> 81295 bytes doc/src/declarative/pics/declarative-adv-tutorial2.png | Bin 0 -> 170388 bytes doc/src/declarative/pics/declarative-adv-tutorial3.png | Bin 0 -> 220052 bytes doc/src/declarative/pics/declarative-adv-tutorial4.png | Bin 0 -> 273086 bytes 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 doc/src/declarative/pics/declarative-adv-tutorial1.png create mode 100644 doc/src/declarative/pics/declarative-adv-tutorial2.png create mode 100644 doc/src/declarative/pics/declarative-adv-tutorial3.png create mode 100644 doc/src/declarative/pics/declarative-adv-tutorial4.png diff --git a/doc/src/declarative/pics/declarative-adv-tutorial1.png b/doc/src/declarative/pics/declarative-adv-tutorial1.png new file mode 100644 index 0000000..990a329 Binary files /dev/null and b/doc/src/declarative/pics/declarative-adv-tutorial1.png differ diff --git a/doc/src/declarative/pics/declarative-adv-tutorial2.png b/doc/src/declarative/pics/declarative-adv-tutorial2.png new file mode 100644 index 0000000..b410d50 Binary files /dev/null and b/doc/src/declarative/pics/declarative-adv-tutorial2.png differ diff --git a/doc/src/declarative/pics/declarative-adv-tutorial3.png b/doc/src/declarative/pics/declarative-adv-tutorial3.png new file mode 100644 index 0000000..e192772 Binary files /dev/null and b/doc/src/declarative/pics/declarative-adv-tutorial3.png differ diff --git a/doc/src/declarative/pics/declarative-adv-tutorial4.png b/doc/src/declarative/pics/declarative-adv-tutorial4.png new file mode 100644 index 0000000..03c9f46 Binary files /dev/null and b/doc/src/declarative/pics/declarative-adv-tutorial4.png differ -- cgit v0.12 From 19d080d319dccac15654294af80530bed9ef11ea Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 7 Oct 2009 13:12:24 +1000 Subject: Switch Same Game tutorial to using snippets properly --- doc/src/declarative/advtutorial1.qdoc | 80 +--------- doc/src/declarative/advtutorial2.qdoc | 76 +--------- doc/src/declarative/advtutorial3.qdoc | 166 ++------------------- doc/src/declarative/advtutorial4.qdoc | 80 ++-------- .../declarative/pics/declarative-adv-tutorial4.gif | Bin 0 -> 58337629 bytes .../declarative/pics/declarative-adv-tutorial4.png | Bin 273086 -> 0 bytes .../tutorials/samegame/samegame1/Block.qml | 2 + .../tutorials/samegame/samegame1/Button.qml | 2 + .../tutorials/samegame/samegame1/samegame.qml | 2 + .../tutorials/samegame/samegame2/samegame.js | 2 + .../tutorials/samegame/samegame2/samegame.qml | 4 + .../tutorials/samegame/samegame3/Block.qml | 2 + .../tutorials/samegame/samegame3/Dialog.qml | 2 + .../tutorials/samegame/samegame3/samegame.js | 4 + .../tutorials/samegame/samegame3/samegame.qml | 6 + .../samegame/samegame4/content/BoomBlock.qml | 10 +- .../samegame/samegame4/content/samegame.js | 2 + 17 files changed, 73 insertions(+), 367 deletions(-) create mode 100644 doc/src/declarative/pics/declarative-adv-tutorial4.gif delete mode 100644 doc/src/declarative/pics/declarative-adv-tutorial4.png diff --git a/doc/src/declarative/advtutorial1.qdoc b/doc/src/declarative/advtutorial1.qdoc index b940986..48b32cd 100644 --- a/doc/src/declarative/advtutorial1.qdoc +++ b/doc/src/declarative/advtutorial1.qdoc @@ -10,46 +10,7 @@ The first step is to create the items in your application. In Same Game we have Here is the QML code for the basic elements. The game window: -\code -import Qt 4.6 - -Rectangle { - id: Screen - width: 490; height: 720 - - SystemPalette { id: activePalette; colorGroup: Qt.Active } - - Item { - width: parent.width; anchors.top: parent.top; anchors.bottom: ToolBar.top - - Image { - id: background - anchors.fill: parent; source: "pics/background.png" - fillMode: "PreserveAspectCrop" - } - } - - Rectangle { - id: ToolBar - color: activePalette.window - height: 32; width: parent.width - anchors.bottom: Screen.bottom - - Button { - id: btnA; text: "New Game"; onClicked: print("Implement me!"); - anchors.left: parent.left; anchors.leftMargin: 3 - anchors.verticalCenter: parent.verticalCenter - } - - Text { - id: Score - text: "Score: Who knows?"; font.bold: true - anchors.right: parent.right; anchors.rightMargin: 3 - anchors.verticalCenter: parent.verticalCenter - } - } -} -\endcode +\snippet declarative/tutorials/samegame/samegame1/samegame.qml 0 This gives you a basic game window, with room for the game canvas. A new game button and room to display the score. The one thing you may not recognize here @@ -59,49 +20,14 @@ feel you would use a QPushButton). Since we want a fully QML button, and the Fx primitives don't include a button, we had to write our own. Below is the code which we wrote to do this: -\code -import Qt 4.6 - -Rectangle { - id: Container - - signal clicked - property string text: "Button" - - color: activePalette.button; smooth: true - width: txtItem.width + 20; height: txtItem.height + 6 - border.width: 1; border.color: activePalette.darker(activePalette.button); radius: 8; - - gradient: Gradient { - GradientStop { - id: topGrad; position: 0.0 - color: if (mr.pressed) { activePalette.dark } else { activePalette.light } } - GradientStop { position: 1.0; color: activePalette.button } - } - - MouseRegion { id: mr; anchors.fill: parent; onClicked: Container.clicked() } +\snippet declarative/tutorials/samegame/samegame1/Button.qml 0 - Text { - id: txtItem; text: Container.text; anchors.centerIn: Container; color: activePalette.buttonText - } -} -\endcode Note that this Button component was written to be fairly generic, in case we want to use a similarly styled button later. And here is a simple block: -\code -import Qt 4.6 -Item { - id:block - - Image { id: img - source: "pics/redStone.png"; - anchors.fill: parent - } -} -\endcode +\snippet declarative/tutorials/samegame/samegame1/Block.qml 0 Since it doesn't do anything yet it's very simple, just an image. As the tutorial progresses and the block starts doing things the file will become diff --git a/doc/src/declarative/advtutorial2.qdoc b/doc/src/declarative/advtutorial2.qdoc index c17f9c4..2d2fe19 100644 --- a/doc/src/declarative/advtutorial2.qdoc +++ b/doc/src/declarative/advtutorial2.qdoc @@ -13,68 +13,7 @@ in the ECMA script, as opposed to using a Repeater. This adds enough script to justify a new file, samegame.js, the intial version of which is shown below -\code -//Note that X/Y referred to here are in game coordinates -var maxX = 10;//Nums are for tileSize 40 -var maxY = 15; -var tileSize = 40; -var maxIndex = maxX*maxY; -var board = new Array(maxIndex); -var tileSrc = "Block.qml"; -var component; - -//Index function used instead of a 2D array -function index(xIdx,yIdx) { - return xIdx + (yIdx * maxX); -} - -function initBoard() -{ - //Calculate board size - maxX = Math.floor(background.width/tileSize); - maxY = Math.floor(background.height/tileSize); - maxIndex = maxY*maxX; - - //Initialize Board - board = new Array(maxIndex); - for(xIdx=0; xIdx= maxX || xIdx < 0 || yIdx >= maxY || yIdx < 0) - return; - if(board[index(xIdx, yIdx)] == null) - return; - //If it's a valid tile, remove it and all connected (does nothing if it's not connected) - floodFill(xIdx,yIdx, -1); - if(fillFound <= 0) - return; - gameCanvas.score += (fillFound - 1) * (fillFound - 1); - shuffleDown(); - victoryCheck(); -} - -function victoryCheck() -{ - //awards bonuses for no tiles left - deservesBonus = true; - for(xIdx=maxX-1; xIdx>=0; xIdx--) - if(board[index(xIdx, maxY - 1)] != null) - deservesBonus = false; - if(deservesBonus) - gameCanvas.score += 500; - //Checks for game over - if(deservesBonus || !(floodMoveCheck(0,maxY-1, -1))) - dialog.show("Game Over. Your score is " + gameCanvas.score); -} -\endcode +\snippet declarative/tutorials/samegame/samegame3/samegame.js 1 +\snippet declarative/tutorials/samegame/samegame3/samegame.js 2 You'll notice them referring to the 'gameCanvas' item. This is an item that has been added to the QML for easy interfacing. It is placed next to the background image and replaces the background as the item to create the blocks in. Its code is shown below: -\code - Item { - id: gameCanvas - property int score: 0 - property int tileSize: 40 - - z: 20; anchors.centerIn: parent - width: parent.width - (parent.width % tileSize); - height: parent.height - (parent.height % tileSize); - - MouseRegion { - id: gameMR - anchors.fill: parent; onClicked: handleClick(mouse.x,mouse.y); - } - } -\endcode + +\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. 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. 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: -\code -import Qt 4.6 - -Rectangle { - id: page - function forceClose() { - page.closed(); - page.opacity = 0; - } - function show(txt) { - MyText.text = txt; - page.opacity = 1; - } - signal closed(); - color: "white"; border.width: 1; width: MyText.width + 20; height: 60; - opacity: 0 - opacity: Behavior { - NumberAnimation { duration: 1000 } - } - Text { id: MyText; anchors.centerIn: parent; text: "Hello World!" } - MouseRegion { id: mr; anchors.fill: parent; onClicked: forceClose(); } -} -\endcode + +\snippet declarative/tutorials/samegame/samegame3/Dialog.qml 0 + And this is how it's used in the main QML file: -\code - Dialog { id: dialog; anchors.centerIn: parent; z: 21 } -\endcode + +\snippet declarative/tutorials/samegame/samegame3/samegame.qml 2 + Combined with the line of code in victoryCheck, this causes a dialog to appear when the game is over, informing the user of that fact. We now have a working game! The blocks can be clicked, the player can score, and the game can end (and then you start a new one). Below is a screenshot of what has been accomplished so far: @@ -107,87 +43,11 @@ We now have a working game! The blocks can be clicked, the player can score, and Here is the QML code as it is now for the main file: -\code -import Qt 4.6 - -Rectangle { - id: Screen - width: 490; height: 720 - - SystemPalette { id: activePalette; colorGroup: Qt.Active } - Script { source: "samegame.js" } - - Item { - width: parent.width; anchors.top: parent.top; anchors.bottom: ToolBar.top - - Image { - id: background - anchors.fill: parent; source: "pics/background.png" - fillMode: "PreserveAspectCrop" - } - - Item { - id: gameCanvas - property int score: 0 - property int tileSize: 40 - - z: 20; anchors.centerIn: parent - width: parent.width - (parent.width % tileSize); - height: parent.height - (parent.height % tileSize); - - MouseRegion { - id: gameMR - anchors.fill: parent; onClicked: handleClick(mouse.x,mouse.y); - } - } - } - - Dialog { id: dialog; anchors.centerIn: parent; z: 21 } - - Rectangle { - id: ToolBar - color: activePalette.window - height: 32; width: parent.width - anchors.bottom: Screen.bottom - - Button { - id: btnA; text: "New Game"; onClicked: initBoard(); - anchors.left: parent.left; anchors.leftMargin: 3 - anchors.verticalCenter: parent.verticalCenter - } - - Text { - id: Score - text: "Score: " + gameCanvas.score; font.bold: true - anchors.right: parent.right; anchors.rightMargin: 3 - anchors.verticalCenter: parent.verticalCenter - } - } -} -\endcode +\snippet declarative/tutorials/samegame/samegame3/samegame.qml 0 And the code for the block: -\code -import Qt 4.6 - -Item { - id:block - property int type: 0 - - Image { id: img - source: { - if(type == 0){ - "pics/redStone.png"; - } else if(type == 1) { - "pics/blueStone.png"; - } else { - "pics/greenStone.png"; - } - } - anchors.fill: parent - } -} -\endcode + +\snippet declarative/tutorials/samegame/samegame3/Block.qml 0 The game works, but it's a little boring right now. Where's the smooth animated transitions? Where's the high scores? If you were a QML expert you could have written these in for the first iteration, but in this tutorial they've been saved until the next chapter - where your application becomes alive! diff --git a/doc/src/declarative/advtutorial4.qdoc b/doc/src/declarative/advtutorial4.qdoc index 5ad1ec3..291d2f2 100644 --- a/doc/src/declarative/advtutorial4.qdoc +++ b/doc/src/declarative/advtutorial4.qdoc @@ -10,6 +10,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: + \code property int targetX: 0 property int targetY: 0 @@ -20,32 +21,11 @@ The most vital animations are that the blocks move fluidly around the board. QML 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: -\code - property bool spawned: false - property int targetX: 0 - property int targetY: 0 - - x: SpringFollow { enabled: spawned; source: targetX; spring: 2; damping: 0.2 } - y: SpringFollow { source: targetY; spring: 2; damping: 0.2 } -\endcode +\snippet declarative/tutorials/samegame/samegame4/content/BoomBlock.qml 1 The next-most vital animation is a smooth exit. For this animation, we'll use a Behavior element. A Behavior is also a property value source, and it is much like SpringFollow except that it doesn't model the behavior of a spring. You specify how a Behavior transitions using the standard animations. As we want the blocks to smoothly fade in and out we'll set a Behavior on the block image's opacity, like so: -\code - Image { id: img - source: { - if(type == 0){ - "pics/redStone.png"; - } else if(type == 1) { - "pics/blueStone.png"; - } else { - "pics/greenStone.png"; - } - } - opacity: 0 - opacity: Behavior { NumberAnimation { properties:"opacity"; duration: 200 } } - anchors.fill: parent - } -\endcode + +\snippet declarative/tutorials/samegame/samegame4/content/BoomBlock.qml 2 Note that the 'opacity: 0' makes it start out transparent. We could set the opacity in the script file when we create the blocks, but instead we use states (as this is useful for the next animation we'll implement). The below snippet is set on the root element of Block.qml: \code @@ -62,53 +42,25 @@ Note that the 'opacity: 0' makes it start out transparent. We could set the opac Now it will automatically fade in, as we set spawned to true already when implementing the block movement animations. To fade out, we set 'dying' to true instead of setting opacity to 0 when a block is destroyed (in the floodFill function). The least vital animations are a cool-looking particle effect when they get destroyed. First we create a Particles Element in the block, like so: -\code - Particles { id: particles - width:1; height:1; anchors.centerIn: parent; opacity: 0 - lifeSpan: 700; lifeSpanDeviation: 600; count:0; streamIn: false - angle: 0; angleDeviation: 360; velocity: 100; velocityDeviation:30 - source: { - if(type == 0){ - "pics/redStar.png"; - } else if (type == 1) { - "pics/blueStar.png"; - } else { - "pics/greenStar.png"; - } - } - } -\endcode + +\snippet declarative/tutorials/samegame/samegame4/content/BoomBlock.qml 3 + To fully understand this you'll want to look at the Particles element documentation, but it's important to note that count is set to zero. -We next extend the 'dying' state, which triggers the particles by setting the count to non-zero. The code for that state looks like this: -\code - State{ name: "DeathState"; when: dying == true - PropertyChanges { target: particles; count: 50 } - PropertyChanges { target: particles; opacity: 1 } - PropertyChanges { target: particles; emitting: false } // i.e. emit only once - PropertyChanges { target: img; opacity: 0 } - } -\endcode -And now the game should be beautifully animated and smooth, with a subtle (or not-so-subtle) animation added for all of the player's actions. +We next extend the 'dying' state, which triggers the particles by setting the count to non-zero. The code for the states now look like this: + +\snippet declarative/tutorials/samegame/samegame4/content/BoomBlock.qml 4 + +And now the game should be beautifully animated and smooth, with a subtle (or not-so-subtle) animation added for all of the player's actions. The end result is shown below: + +\image declarative-adv-tutorial4.gif \section2 Web-based High Scores Another extension we might want for the game is some way of storing and retriveing high scores. In this tutorial we'll show you how to integrate a web enabled high score storage into your QML application. The implementation we've done is very simple - the high score data is posted to a php script running on a server somewhere, and that server then stores it and displays it to visitors. You could request an XML or QML file from that same server, which contained and displayed the scores, but that's beyond the scope of this tutorial. For better high score data, we want the name and time of the player. The time is obtained in the script fairly simply, but we have to ask the player for their name. We thus re-use the dialog QML file to pop up a dialog asking for the player's name (and if they exit this dialog without entering it they have a way to opt out of posting their high score). When the dialog is closed, if the player entered their name we can send the data to the web service in the followign snippet out of the script file: -\code -function sendHighScore(name) { - var postman = new XMLHttpRequest() - var postData = "name="+name+"&score="+gameCanvas.score - +"&gridSize="+maxX+"x"+maxY +"&time="+Math.floor(timer/1000); - postman.open("POST", scoresURL, true); - postman.onreadystatechange = function() { - if (postman.readyState == postman.DONE) { - dialog.show("Your score has been uploaded."); - } - } - postman.send(postData); -} -\endcode + +\snippet declarative/tutorials/samegame/samegame4/content/samegame.js 1 This is the same XMLHttpRequest() as you'll find in browser javascript, and can be used in the same way to dynamically get XML or QML from the web service to display the high scores. We don't worry about the response here though, we just post the high score data to the web server. If it had returned a QML file (or a URL to a QML file) you could instantiate it in much the same way as you did the blocks. diff --git a/doc/src/declarative/pics/declarative-adv-tutorial4.gif b/doc/src/declarative/pics/declarative-adv-tutorial4.gif new file mode 100644 index 0000000..a67666d Binary files /dev/null and b/doc/src/declarative/pics/declarative-adv-tutorial4.gif differ diff --git a/doc/src/declarative/pics/declarative-adv-tutorial4.png b/doc/src/declarative/pics/declarative-adv-tutorial4.png deleted file mode 100644 index 03c9f46..0000000 Binary files a/doc/src/declarative/pics/declarative-adv-tutorial4.png and /dev/null differ diff --git a/examples/declarative/tutorials/samegame/samegame1/Block.qml b/examples/declarative/tutorials/samegame/samegame1/Block.qml index 228ac4e..b76e61a 100644 --- a/examples/declarative/tutorials/samegame/samegame1/Block.qml +++ b/examples/declarative/tutorials/samegame/samegame1/Block.qml @@ -1,3 +1,4 @@ +//![0] import Qt 4.6 Item { @@ -8,3 +9,4 @@ Item { anchors.fill: parent } } +//![0] diff --git a/examples/declarative/tutorials/samegame/samegame1/Button.qml b/examples/declarative/tutorials/samegame/samegame1/Button.qml index 2354218..3846cf7 100644 --- a/examples/declarative/tutorials/samegame/samegame1/Button.qml +++ b/examples/declarative/tutorials/samegame/samegame1/Button.qml @@ -1,3 +1,4 @@ +//![0] import Qt 4.6 Rectangle { @@ -23,3 +24,4 @@ Rectangle { id: txtItem; text: Container.text; anchors.centerIn: Container; color: activePalette.buttonText } } +//![0] diff --git a/examples/declarative/tutorials/samegame/samegame1/samegame.qml b/examples/declarative/tutorials/samegame/samegame1/samegame.qml index d18718d..8b32cae 100644 --- a/examples/declarative/tutorials/samegame/samegame1/samegame.qml +++ b/examples/declarative/tutorials/samegame/samegame1/samegame.qml @@ -1,3 +1,4 @@ +//![0] import Qt 4.6 Rectangle { @@ -36,3 +37,4 @@ Rectangle { } } } +//![0] diff --git a/examples/declarative/tutorials/samegame/samegame2/samegame.js b/examples/declarative/tutorials/samegame/samegame2/samegame.js index 064d87e..2bf68b5 100644 --- a/examples/declarative/tutorials/samegame/samegame2/samegame.js +++ b/examples/declarative/tutorials/samegame/samegame2/samegame.js @@ -1,3 +1,4 @@ +//![0] //Note that X/Y referred to here are in game coordinates var maxX = 10;//Nums are for tileSize 40 var maxY = 15; @@ -57,3 +58,4 @@ function createBlock(xIdx,yIdx){ } return true; } +//![0] diff --git a/examples/declarative/tutorials/samegame/samegame2/samegame.qml b/examples/declarative/tutorials/samegame/samegame2/samegame.qml index e446fa4..78a3d83 100644 --- a/examples/declarative/tutorials/samegame/samegame2/samegame.qml +++ b/examples/declarative/tutorials/samegame/samegame2/samegame.qml @@ -5,7 +5,9 @@ Rectangle { width: 490; height: 720 SystemPalette { id: activePalette; colorGroup: Qt.Active } + //![2] Script { source: "samegame.js" } + //![2] Item { width: parent.width; anchors.top: parent.top; anchors.bottom: ToolBar.top @@ -23,11 +25,13 @@ Rectangle { height: 32; width: parent.width anchors.bottom: Screen.bottom + //![1] Button { id: btnA; text: "New Game"; onClicked: initBoard(); anchors.left: parent.left; anchors.leftMargin: 3 anchors.verticalCenter: parent.verticalCenter } + //![1] Text { id: Score diff --git a/examples/declarative/tutorials/samegame/samegame3/Block.qml b/examples/declarative/tutorials/samegame/samegame3/Block.qml index 2f28923..30a8d3a 100644 --- a/examples/declarative/tutorials/samegame/samegame3/Block.qml +++ b/examples/declarative/tutorials/samegame/samegame3/Block.qml @@ -1,3 +1,4 @@ +//![0] import Qt 4.6 Item { @@ -17,3 +18,4 @@ Item { anchors.fill: parent } } +//![0] diff --git a/examples/declarative/tutorials/samegame/samegame3/Dialog.qml b/examples/declarative/tutorials/samegame/samegame3/Dialog.qml index 401d211..5fe6aa0 100644 --- a/examples/declarative/tutorials/samegame/samegame3/Dialog.qml +++ b/examples/declarative/tutorials/samegame/samegame3/Dialog.qml @@ -1,3 +1,4 @@ +//![0] import Qt 4.6 Rectangle { @@ -19,3 +20,4 @@ Rectangle { Text { id: MyText; anchors.centerIn: parent; text: "Hello World!" } MouseRegion { id: mr; anchors.fill: parent; onClicked: forceClose(); } } +//![0] diff --git a/examples/declarative/tutorials/samegame/samegame3/samegame.js b/examples/declarative/tutorials/samegame/samegame3/samegame.js index 16b349d..8fecfef 100644 --- a/examples/declarative/tutorials/samegame/samegame3/samegame.js +++ b/examples/declarative/tutorials/samegame/samegame3/samegame.js @@ -72,6 +72,7 @@ function createBlock(xIdx,yIdx){ var fillFound;//Set after a floodFill call to the number of tiles found var floodBoard;//Set to 1 if the floodFill reaches off that node //NOTE: Be careful with vars named x,y, as the calling object's x,y are still in scope +//![1] function handleClick(x,y) { xIdx = Math.floor(x/gameCanvas.tileSize); @@ -88,6 +89,7 @@ function handleClick(x,y) shuffleDown(); victoryCheck(); } +//![1] function floodFill(xIdx,yIdx,type) { @@ -156,6 +158,7 @@ function shuffleDown() } } +//![2] function victoryCheck() { //awards bonuses for no tiles left @@ -169,6 +172,7 @@ function victoryCheck() if(deservesBonus || !(floodMoveCheck(0,maxY-1, -1))) dialog.show("Game Over. Your score is " + gameCanvas.score); } +//![2] //only floods up and right, to see if it can find adjacent same-typed tiles function floodMoveCheck(xIdx, yIdx, type) diff --git a/examples/declarative/tutorials/samegame/samegame3/samegame.qml b/examples/declarative/tutorials/samegame/samegame3/samegame.qml index ea43ab2..a0883da 100644 --- a/examples/declarative/tutorials/samegame/samegame3/samegame.qml +++ b/examples/declarative/tutorials/samegame/samegame3/samegame.qml @@ -1,3 +1,4 @@ +//![0] import Qt 4.6 Rectangle { @@ -16,6 +17,7 @@ Rectangle { fillMode: "PreserveAspectCrop" } + //![1] Item { id: gameCanvas property int score: 0 @@ -30,9 +32,12 @@ Rectangle { anchors.fill: parent; onClicked: handleClick(mouse.x,mouse.y); } } + //![1] } + //![2] Dialog { id: dialog; anchors.centerIn: parent; z: 21 } + //![2] Rectangle { id: ToolBar @@ -54,3 +59,4 @@ Rectangle { } } } +//![0] diff --git a/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml b/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml index a495cd0..7ad8b07 100644 --- a/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml +++ b/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml @@ -1,15 +1,18 @@ import Qt 4.6 Item { id:block + property int type: 0 property bool dying: false + //![1] property bool spawned: false - property int type: 0 property int targetX: 0 property int targetY: 0 x: SpringFollow { enabled: spawned; source: targetX; spring: 2; damping: 0.2 } y: SpringFollow { source: targetY; spring: 2; damping: 0.2 } + //![1] + //![2] Image { id: img source: { if(type == 0){ @@ -24,7 +27,9 @@ Item { id:block opacity: Behavior { NumberAnimation { properties:"opacity"; duration: 200 } } anchors.fill: parent } + //![2] + //![3] Particles { id: particles width:1; height:1; anchors.centerIn: parent; opacity: 0 lifeSpan: 700; lifeSpanDeviation: 600; count:0; streamIn: false @@ -39,7 +44,9 @@ Item { id:block } } } + //![3] + //![4] states: [ State{ name: "AliveState"; when: spawned == true && dying == false PropertyChanges { target: img; opacity: 1 } @@ -51,4 +58,5 @@ Item { id:block PropertyChanges { target: img; opacity: 0 } } ] + //![4] } diff --git a/examples/declarative/tutorials/samegame/samegame4/content/samegame.js b/examples/declarative/tutorials/samegame/samegame4/content/samegame.js index cf55b59..ce9c169 100755 --- a/examples/declarative/tutorials/samegame/samegame4/content/samegame.js +++ b/examples/declarative/tutorials/samegame/samegame4/content/samegame.js @@ -203,6 +203,7 @@ function createBlock(xIdx,yIdx){ return true; } +//![1] function sendHighScore(name) { var postman = new XMLHttpRequest() var postData = "name="+name+"&score="+gameCanvas.score @@ -215,3 +216,4 @@ function sendHighScore(name) { } postman.send(postData); } +//![1] -- cgit v0.12 From 07b3465405ccd59dc5c447cffc47cc1a17f674f0 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 7 Oct 2009 15:18:06 +1000 Subject: Add three failing tests to the QML ECMAscript autotest Tests the creation, deletion and toString functions for QML objects. Task-number: QT-2252 --- .../qmlecmascript/data/dynamicCreation.helper.qml | 5 ++ .../qmlecmascript/data/dynamicCreation.qml | 16 +++++ .../qmlecmascript/data/dynamicDeletion.qml | 20 +++++++ .../declarative/qmlecmascript/data/qmlToString.qml | 11 ++++ .../qmlecmascript/tst_qmlecmascript.cpp | 69 ++++++++++++++++++++++ 5 files changed, 121 insertions(+) create mode 100644 tests/auto/declarative/qmlecmascript/data/dynamicCreation.helper.qml create mode 100644 tests/auto/declarative/qmlecmascript/data/dynamicCreation.qml create mode 100644 tests/auto/declarative/qmlecmascript/data/dynamicDeletion.qml create mode 100644 tests/auto/declarative/qmlecmascript/data/qmlToString.qml diff --git a/tests/auto/declarative/qmlecmascript/data/dynamicCreation.helper.qml b/tests/auto/declarative/qmlecmascript/data/dynamicCreation.helper.qml new file mode 100644 index 0000000..58ca26e --- /dev/null +++ b/tests/auto/declarative/qmlecmascript/data/dynamicCreation.helper.qml @@ -0,0 +1,5 @@ +import Qt.Test 1.0 + +MyQmlObject{ + objectName: "desolateObject" +} diff --git a/tests/auto/declarative/qmlecmascript/data/dynamicCreation.qml b/tests/auto/declarative/qmlecmascript/data/dynamicCreation.qml new file mode 100644 index 0000000..f3eb75f --- /dev/null +++ b/tests/auto/declarative/qmlecmascript/data/dynamicCreation.qml @@ -0,0 +1,16 @@ +import Qt.test 1.0 + +MyQmlObject{ + id: obj + objectName: "obj" + function createOne() + { + obj.objectProperty = createQmlObject('import Qt.test 1.0; MyQmlObject{objectName:"emptyObject"}', obj); + } + + function createTwo() + { + var component = createComponent('dynamicCreation.helper.qml'); + obj.objectProperty = component.createObject(); + } +} diff --git a/tests/auto/declarative/qmlecmascript/data/dynamicDeletion.qml b/tests/auto/declarative/qmlecmascript/data/dynamicDeletion.qml new file mode 100644 index 0000000..618723f --- /dev/null +++ b/tests/auto/declarative/qmlecmascript/data/dynamicDeletion.qml @@ -0,0 +1,20 @@ +import Qt.test 1.0 + +MyQmlObject{ + id: obj + objectName: "obj" + function create() + { + obj.objectProperty = createQmlObject('import Qt.test 1.0; MyQmlObject{objectName:"emptyObject"}', obj); + } + + function killIt(wait) + { + if(obj.objectProperty == undefined || obj.objectProperty == null) + return; + if(wait > 0) + obj.objectProperty.destroy(wait); + else + obj.objectProperty.destroy(); + } +} diff --git a/tests/auto/declarative/qmlecmascript/data/qmlToString.qml b/tests/auto/declarative/qmlecmascript/data/qmlToString.qml new file mode 100644 index 0000000..ac296ce --- /dev/null +++ b/tests/auto/declarative/qmlecmascript/data/qmlToString.qml @@ -0,0 +1,11 @@ +import Qt.test 1.0 + +MyQmlObject{ + id: obj + objectName: "objName" + function testToString() + { + obj.stringProperty = obj.toString(); + } + +} diff --git a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp index d5d20b6..778b37f 100644 --- a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp +++ b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "testtypes.h" @@ -50,6 +51,9 @@ private slots: void outerBindingOverridesInnerBinding(); void aliasPropertyAndBinding(); void nonExistantAttachedObject(); + void dynamicCreation(); + void dynamicDestruction(); + void objectToString(); private: QmlEngine engine; @@ -531,6 +535,71 @@ void tst_qmlecmascript::aliasPropertyAndBinding() QCOMPARE(object->property("c3").toInt(), 19); } +/* + Test using createQmlObject to dynamically generate an item + Also using createComponent is tested. +*/ +void tst_qmlecmascript::dynamicCreation() +{ + QmlComponent component(&engine, TEST_FILE("dynamicCreation.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QObject *createdQmlObject = 0; + QObject *createdComponent = 0; + + QMetaObject::invokeMethod(object, "createOne"); + createdQmlObject = object->objectProperty(); + QVERIFY(createdQmlObject); + QCOMPARE(createdQmlObject->objectName(), QString("emptyObject")); + + QMetaObject::invokeMethod(object, "createTwo"); + createdComponent = object->objectProperty(); + QVERIFY(createdComponent); + QCOMPARE(createdQmlObject->objectName(), QString("desolateObject")); +} + +/* + Tests the destroy function +*/ +void tst_qmlecmascript::dynamicDestruction() +{ + QmlComponent component(&engine, TEST_FILE("dynamicDeletion.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QGuard createdQmlObject = 0; + + QMetaObject::invokeMethod(object, "create"); + createdQmlObject = object->objectProperty(); + QVERIFY(createdQmlObject); + QCOMPARE(createdQmlObject->objectName(), QString("emptyObject")); + + QMetaObject::invokeMethod(object, "killIt", Q_ARG(int, 0)); + QVERIFY(createdQmlObject); + QTest::qWait(0); + QVERIFY(!createdQmlObject); + + QMetaObject::invokeMethod(object, "create"); + QVERIFY(createdQmlObject); + QMetaObject::invokeMethod(object, "killIt", Q_ARG(int, 100)); + QVERIFY(createdQmlObject); + QTest::qWait(0); + QVERIFY(createdQmlObject); + QTest::qWait(100); + QVERIFY(!createdQmlObject); +} + +/* + tests that id.toString() works +*/ +void tst_qmlecmascript::objectToString() +{ + QmlComponent component(&engine, TEST_FILE("qmlToString.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QMetaObject::invokeMethod(object, "testToString"); + QVERIFY(object->stringProperty().startsWith("Qml Object, \"objName\" MyQmlObject_QML_15")); +} + QTEST_MAIN(tst_qmlecmascript) #include "tst_qmlecmascript.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 8b0cac9179de4d1cb34b9f17932d34cef3cd4f5b Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 7 Oct 2009 15:42:53 +1000 Subject: Get two of those new autotests to pass. The third will not pass until QT-2240 is fixed. --- .../qmlecmascript/data/dynamicCreation.helper.qml | 4 ++-- .../qmlecmascript/data/dynamicCreation.qml | 2 +- .../qmlecmascript/data/dynamicDeletion.qml | 14 +++++++------- .../declarative/qmlecmascript/tst_qmlecmascript.cpp | 20 +++++++++----------- 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/tests/auto/declarative/qmlecmascript/data/dynamicCreation.helper.qml b/tests/auto/declarative/qmlecmascript/data/dynamicCreation.helper.qml index 58ca26e..b26d6e1 100644 --- a/tests/auto/declarative/qmlecmascript/data/dynamicCreation.helper.qml +++ b/tests/auto/declarative/qmlecmascript/data/dynamicCreation.helper.qml @@ -1,5 +1,5 @@ -import Qt.Test 1.0 +import Qt.test 1.0 MyQmlObject{ - objectName: "desolateObject" + objectName: "objectTwo" } diff --git a/tests/auto/declarative/qmlecmascript/data/dynamicCreation.qml b/tests/auto/declarative/qmlecmascript/data/dynamicCreation.qml index f3eb75f..ef39590 100644 --- a/tests/auto/declarative/qmlecmascript/data/dynamicCreation.qml +++ b/tests/auto/declarative/qmlecmascript/data/dynamicCreation.qml @@ -5,7 +5,7 @@ MyQmlObject{ objectName: "obj" function createOne() { - obj.objectProperty = createQmlObject('import Qt.test 1.0; MyQmlObject{objectName:"emptyObject"}', obj); + obj.objectProperty = createQmlObject('import Qt.test 1.0; MyQmlObject{objectName:"objectOne"}', obj); } function createTwo() diff --git a/tests/auto/declarative/qmlecmascript/data/dynamicDeletion.qml b/tests/auto/declarative/qmlecmascript/data/dynamicDeletion.qml index 618723f..ba87b32 100644 --- a/tests/auto/declarative/qmlecmascript/data/dynamicDeletion.qml +++ b/tests/auto/declarative/qmlecmascript/data/dynamicDeletion.qml @@ -8,13 +8,13 @@ MyQmlObject{ obj.objectProperty = createQmlObject('import Qt.test 1.0; MyQmlObject{objectName:"emptyObject"}', obj); } - function killIt(wait) + function killOther() { - if(obj.objectProperty == undefined || obj.objectProperty == null) - return; - if(wait > 0) - obj.objectProperty.destroy(wait); - else - obj.objectProperty.destroy(); + obj.objectProperty.destroy(100); + } + + function killMe() + { + obj.destroy();//Must not segfault } } diff --git a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp index 778b37f..3f01192 100644 --- a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp +++ b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp @@ -550,12 +550,12 @@ void tst_qmlecmascript::dynamicCreation() QMetaObject::invokeMethod(object, "createOne"); createdQmlObject = object->objectProperty(); QVERIFY(createdQmlObject); - QCOMPARE(createdQmlObject->objectName(), QString("emptyObject")); + QCOMPARE(createdQmlObject->objectName(), QString("objectOne")); QMetaObject::invokeMethod(object, "createTwo"); createdComponent = object->objectProperty(); QVERIFY(createdComponent); - QCOMPARE(createdQmlObject->objectName(), QString("desolateObject")); + QCOMPARE(createdComponent->objectName(), QString("objectTwo")); } /* @@ -564,7 +564,7 @@ void tst_qmlecmascript::dynamicCreation() void tst_qmlecmascript::dynamicDestruction() { QmlComponent component(&engine, TEST_FILE("dynamicDeletion.qml")); - MyQmlObject *object = qobject_cast(component.create()); + QGuard object = qobject_cast(component.create()); QVERIFY(object != 0); QGuard createdQmlObject = 0; @@ -573,19 +573,17 @@ void tst_qmlecmascript::dynamicDestruction() QVERIFY(createdQmlObject); QCOMPARE(createdQmlObject->objectName(), QString("emptyObject")); - QMetaObject::invokeMethod(object, "killIt", Q_ARG(int, 0)); - QVERIFY(createdQmlObject); - QTest::qWait(0); - QVERIFY(!createdQmlObject); - - QMetaObject::invokeMethod(object, "create"); - QVERIFY(createdQmlObject); - QMetaObject::invokeMethod(object, "killIt", Q_ARG(int, 100)); + QMetaObject::invokeMethod(object, "killOther"); QVERIFY(createdQmlObject); QTest::qWait(0); QVERIFY(createdQmlObject); QTest::qWait(100); QVERIFY(!createdQmlObject); + + QMetaObject::invokeMethod(object, "killMe"); + QVERIFY(object); + QTest::qWait(0); + QVERIFY(!object); } /* -- 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 From f36619d24bc1a2b1e9bef6b4fac7d5d9a1916b7c Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 8 Oct 2009 14:04:31 +1000 Subject: Fix (properly) test image saving. --- 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 87ab43b..8005b0e 100644 --- a/tools/qmlviewer/qfxtester.cpp +++ b/tools/qmlviewer/qfxtester.cpp @@ -161,8 +161,9 @@ void QFxTester::save() if (!fe.hash.isEmpty()) { ts << " hash: \"" << fe.hash.toHex() << "\"\n"; } else if (!fe.image.isNull()) { - QString filename = filenameInfo.baseName() + "." + QString::number(imgCount++) + ".png"; - fe.image.save(filename); + QString filename = filenameInfo.baseName() + "." + QString::number(imgCount) + ".png"; + fe.image.save(m_script + "." + QString::number(imgCount) + ".png"); + imgCount++; ts << " image: \"" << filename << "\"\n"; } ts << " }\n"; -- cgit v0.12 From 87504046a111a4154349f6189ecc51ca85c48670 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 8 Oct 2009 14:21:39 +1000 Subject: WebView auto sizing test. (image is just for doc, not in testscript) --- .../visual/qfxwebview/autosize/autosize.qml | 60 +++++++++++++++ .../visual/qfxwebview/autosize/data/autosize.0.png | Bin 0 -> 6886 bytes .../visual/qfxwebview/autosize/data/autosize.qml | 83 +++++++++++++++++++++ 3 files changed, 143 insertions(+) create mode 100644 tests/auto/declarative/visual/qfxwebview/autosize/autosize.qml create mode 100644 tests/auto/declarative/visual/qfxwebview/autosize/data/autosize.0.png create mode 100644 tests/auto/declarative/visual/qfxwebview/autosize/data/autosize.qml diff --git a/tests/auto/declarative/visual/qfxwebview/autosize/autosize.qml b/tests/auto/declarative/visual/qfxwebview/autosize/autosize.qml new file mode 100644 index 0000000..74c6844 --- /dev/null +++ b/tests/auto/declarative/visual/qfxwebview/autosize/autosize.qml @@ -0,0 +1,60 @@ +import Qt 4.6 + +// The WebView size is determined by the width, height, +// preferredWidth, and preferredHeight properties. +Rectangle { + id: rect + color: "white" + width: 200 + height: layout.height + Column { + id: layout + spacing: 2 + WebView { + html: "No width defined." + Rectangle { color: "#10000000" + anchors.fill: parent + } + } + WebView { + width: rect.width + html: "The width is full." + Rectangle { + color: "#10000000" + anchors.fill: parent + } + } + WebView { + width: rect.width/2 + html: "The width is half." + Rectangle { + color: "#10000000" + anchors.fill: parent + } + } + WebView { + preferredWidth: rect.width/2 + html: "The preferredWidth is half." + Rectangle { + color: "#10000000" + anchors.fill: parent + } + } + WebView { + preferredWidth: rect.width/2 + html: "The_preferredWidth_is_half." + Rectangle { + color: "#10000000" + anchors.fill: parent + } + } + WebView { + width: rect.width/2 + html: "The_width_is_half." + Rectangle { + color: "#10000000" + anchors.fill: parent + } + } + } +} diff --git a/tests/auto/declarative/visual/qfxwebview/autosize/data/autosize.0.png b/tests/auto/declarative/visual/qfxwebview/autosize/data/autosize.0.png new file mode 100644 index 0000000..1f28b9a Binary files /dev/null and b/tests/auto/declarative/visual/qfxwebview/autosize/data/autosize.0.png differ diff --git a/tests/auto/declarative/visual/qfxwebview/autosize/data/autosize.qml b/tests/auto/declarative/visual/qfxwebview/autosize/data/autosize.qml new file mode 100644 index 0000000..47999be --- /dev/null +++ b/tests/auto/declarative/visual/qfxwebview/autosize/data/autosize.qml @@ -0,0 +1,83 @@ +import Qt.VisualTest 4.6 + +VisualTest { + Frame { + msec: 0 + } + Frame { + msec: 16 + hash: "66539e1b1983d95386b0d30d6e969904" + } + Frame { + msec: 32 + hash: "66539e1b1983d95386b0d30d6e969904" + } + Frame { + msec: 48 + hash: "66539e1b1983d95386b0d30d6e969904" + } + Frame { + msec: 64 + hash: "66539e1b1983d95386b0d30d6e969904" + } + Frame { + msec: 80 + hash: "66539e1b1983d95386b0d30d6e969904" + } + Frame { + msec: 96 + hash: "66539e1b1983d95386b0d30d6e969904" + } + Frame { + msec: 112 + hash: "66539e1b1983d95386b0d30d6e969904" + } + Frame { + msec: 128 + hash: "66539e1b1983d95386b0d30d6e969904" + } + Frame { + msec: 144 + hash: "66539e1b1983d95386b0d30d6e969904" + } + Frame { + msec: 160 + hash: "66539e1b1983d95386b0d30d6e969904" + } + Frame { + msec: 176 + hash: "66539e1b1983d95386b0d30d6e969904" + } + Frame { + msec: 192 + hash: "66539e1b1983d95386b0d30d6e969904" + } + Frame { + msec: 208 + hash: "66539e1b1983d95386b0d30d6e969904" + } + Frame { + msec: 224 + hash: "66539e1b1983d95386b0d30d6e969904" + } + Frame { + msec: 240 + hash: "66539e1b1983d95386b0d30d6e969904" + } + Frame { + msec: 256 + hash: "66539e1b1983d95386b0d30d6e969904" + } + Frame { + msec: 272 + hash: "66539e1b1983d95386b0d30d6e969904" + } + Frame { + msec: 288 + hash: "66539e1b1983d95386b0d30d6e969904" + } + Frame { + msec: 304 + hash: "66539e1b1983d95386b0d30d6e969904" + } +} -- cgit v0.12 From 5525a2f1216b03b8a226d4c1d7817024f1010019 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 8 Oct 2009 15:28:00 +1000 Subject: spel --- doc/src/declarative/advtutorial4.qdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/declarative/advtutorial4.qdoc b/doc/src/declarative/advtutorial4.qdoc index ae38c5e..332bf02 100644 --- a/doc/src/declarative/advtutorial4.qdoc +++ b/doc/src/declarative/advtutorial4.qdoc @@ -56,9 +56,9 @@ And now the game should be beautifully animated and smooth, with a subtle (or no \section2 Web-based High Scores -Another extension we might want for the game is some way of storing and retriveing high scores. In this tutorial we'll show you how to integrate a web enabled high score storage into your QML application. The implementation we've done is very simple - the high score data is posted to a php script running on a server somewhere, and that server then stores it and displays it to visitors. You could request an XML or QML file from that same server, which contained and displayed the scores, but that's beyond the scope of this tutorial. +Another extension we might want for the game is some way of storing and retrieving high scores. In this tutorial we'll show you how to integrate a web enabled high score storage into your QML application. The implementation we've done is very simple - the high score data is posted to a php script running on a server somewhere, and that server then stores it and displays it to visitors. You could request an XML or QML file from that same server, which contained and displayed the scores, but that's beyond the scope of this tutorial. -For better high score data, we want the name and time of the player. The time is obtained in the script fairly simply, but we have to ask the player for their name. We thus re-use the dialog QML file to pop up a dialog asking for the player's name (and if they exit this dialog without entering it they have a way to opt out of posting their high score). When the dialog is closed, if the player entered their name we can send the data to the web service in the followign snippet out of the script file: +For better high score data, we want the name and time of the player. The time is obtained in the script fairly simply, but we have to ask the player for their name. We thus re-use the dialog QML file to pop up a dialog asking for the player's name (and if they exit this dialog without entering it they have a way to opt out of posting their high score). When the dialog is closed, if the player entered their name we can send the data to the web service in the following snippet out of the script file: \snippet declarative/tutorials/samegame/samegame4/content/samegame.js 1 -- cgit v0.12 From ca6ec0bd63a8772ceaf947ca25258ef45f58fa60 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Thu, 8 Oct 2009 15:46:12 +1000 Subject: doc cleanup --- doc/src/declarative/advtutorial.qdoc | 48 ++++++++- doc/src/declarative/advtutorial1.qdoc | 56 +++++++++-- doc/src/declarative/advtutorial2.qdoc | 93 +++++++++++++++--- doc/src/declarative/advtutorial3.qdoc | 87 ++++++++++++++--- doc/src/declarative/advtutorial4.qdoc | 107 ++++++++++++++++++--- doc/src/declarative/anchor-layout.qdoc | 41 ++++++++ doc/src/declarative/animation.qdoc | 41 ++++++++ doc/src/declarative/basictypes.qdoc | 41 ++++++++ doc/src/declarative/binding.qdoc | 41 ++++++++ doc/src/declarative/cppitem.qdoc | 41 ++++++++ doc/src/declarative/elements.qdoc | 41 ++++++++ doc/src/declarative/examples.qdoc | 47 ++++++++- doc/src/declarative/focus.qdoc | 41 ++++++++ doc/src/declarative/measuring-performance.qdoc | 41 ++++++++ doc/src/declarative/modules.qdoc | 43 ++++++++- doc/src/declarative/qmlforcpp.qdoc | 41 ++++++++ doc/src/declarative/qmlformat.qdoc | 41 ++++++++ doc/src/declarative/qmlintro.qdoc | 41 ++++++++ doc/src/declarative/qmlmodels.qdoc | 43 ++++++++- doc/src/declarative/qmlreference.qdoc | 54 ++++++++++- doc/src/declarative/qtdeclarative.qdoc | 11 ++- doc/src/declarative/qtprogrammers.qdoc | 41 ++++++++ .../tutorials/samegame/samegame2/samegame.qml | 8 +- .../tutorials/samegame/samegame3/samegame.qml | 8 +- 24 files changed, 1023 insertions(+), 74 deletions(-) diff --git a/doc/src/declarative/advtutorial.qdoc b/doc/src/declarative/advtutorial.qdoc index c8075de..21eab92 100644 --- a/doc/src/declarative/advtutorial.qdoc +++ b/doc/src/declarative/advtutorial.qdoc @@ -1,10 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + /*! \page advtutorial.html \title Advanced Tutorial -This tutorial goes step-by-step through creating a full application using just QML. It is assumed that you already know basic QML (such as from doing the simple tutorial) and the focus is on showing how to turn that knowledge into a complete and functioning application. +This tutorial goes step-by-step through creating a full application using just QML. +It is assumed that you already know basic QML (such as from doing the simple tutorial) and the focus is on showing +how to turn that knowledge into a complete and functioning application. -In this tutorial we recreate, step by step, the Same Game demo in $QTDIR/demos/declarative/samegame.qml. The results of the individual steps are in the $QTDIR/examples/declarative/tutorials/samegame directory. +In this tutorial we recreate, step by step, the Same Game demo in $QTDIR/demos/declarative/samegame.qml. +The results of the individual steps are in the $QTDIR/examples/declarative/tutorials/samegame directory. Tutorial chapters: diff --git a/doc/src/declarative/advtutorial1.qdoc b/doc/src/declarative/advtutorial1.qdoc index 48b32cd..44a9c42 100644 --- a/doc/src/declarative/advtutorial1.qdoc +++ b/doc/src/declarative/advtutorial1.qdoc @@ -1,7 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + /*! \page advtutorial1.html \example declarative/tutorials/samegame/samegame1 -\title Advanced Tutorial 1 - Creating the Game canvas and block +\title Advanced Tutorial 1 - Creating the game canvas and block \target advtutorial1 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. @@ -14,11 +55,10 @@ Here is the QML code for the basic elements. The game window: This gives you a basic game window, with room for the game canvas. A new game button and room to display the score. The one thing you may not recognize here -is the SystemPalette item. This item provides access to the Qt system palette +is the \l SystemPalette item. This item provides access to the Qt system palette and is used to make the button look more like a system button (for exact native -feel you would use a QPushButton). Since we want a fully QML button, and the Fx -primitives don't include a button, we had to write our own. Below is the code -which we wrote to do this: +feel you would use a \l QPushButton). Since we want a fully QML button, and QML does +not include a button, we had to write our own. Below is the code which we wrote to do this: \snippet declarative/tutorials/samegame/samegame1/Button.qml 0 @@ -31,8 +71,10 @@ And here is a simple block: Since it doesn't do anything yet it's very simple, just an image. As the tutorial progresses and the block starts doing things the file will become -more than just an image. Note that we've set the image to be the size of the itm. This will be used later, when we dynamically create and size the block items the image will be scaled automatically to the correct size. - +more than just an image. Note that we've set the image to be the size of the itm. +This will be used later, when we dynamically create and size the block items the image will be scaled automatically +to the correct size. + You should be familiar with all that goes on in these files so far. This is a very basic start and doesn't move at all - next we will populate the game canvas with some blocks. diff --git a/doc/src/declarative/advtutorial2.qdoc b/doc/src/declarative/advtutorial2.qdoc index 2d2fe19..97cd744 100644 --- a/doc/src/declarative/advtutorial2.qdoc +++ b/doc/src/declarative/advtutorial2.qdoc @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + /*! \page advtutorial2.html \title Advanced Tutorial 2 - Populating the Game Canvas @@ -8,37 +49,59 @@ first thing to do is to generate all of the blocks. Now we need to dynamically generate all of these blocks, because you have a new, random set of blocks every time. As they are dynamically generated every time the new game button is clicked, as opposed to on startup, we will be dynamically generating the blocks -in the ECMA script, as opposed to using a Repeater. +in the ECMAScript, as opposed to using a \l Repeater. -This adds enough script to justify a new file, samegame.js, the intial version +This adds enough script to justify a new file, \c{samegame.js}, the intial version of which is shown below \snippet declarative/tutorials/samegame/samegame2/samegame.js 0 -The gist of this code is that we create the blocks dynamically, as many as will fit, and then store them in an array for future reference. The 'initBoard' function will be hooked up to the new game button soon, and should be fairly straight forward. - -The 'createBlock' function is a lot bigger, and I'll explain it block by block. -First we ensure that the component has been constructed. QML elements, including composite ones like the Block.qml that we've written, are never created directly in script. While there is a function to parse and create an arbitrary QML string, in the case where you are repeatedly creating the sme item you will want to use the createComponent function. createComponent is a built-in function in the declarative ECMAscript, and returns a component object. A component object prepares and stores a QML element (usually a composite element) for easy and efficient use. When the component is ready, you can create a new instance of the loaded QML with the createObject method. If the component is loaded remotely (over HTTP fro example) then you will have to wait for the component to finish loading before calling createObject. Since we don't wait here (the waiting is a syncronous, the component object has a signal to tell you when it's done) this code will only work if the block QML is a local file. - -As we aren't waiting for he component, the next block of code creates a game block with component.createObject. Since there could be an error in the QML file you are trying to load, success is not guaranteed. The first bit of error checkign code comes right after createObject(), to ensure that the object loaded correctly. If it did not load correctly the function returns false, but we don't have that hooked up to the main UI to indicate that something has gone wrong. Instead we print out error messages to the console, because an error here means an invalid QML file and should only happen while you are developing and testing the UI. - -Next we start to set up our dynamically created block. Because the Block.qml file is generic it needs to be placed in the main scene, and in the right place. This is why parent, x, y, width and height are set. We then store it in the board array for later use. - -Finally, we have some more error handling. You can only call createObject if the component has loaded. If it has not loaded, either it is still loading or there was an error loading (such as a missing file). Since we don't request remote files the problem is likely to be a missing or misplaced file. Again we print this to the console to aid debugging. +The gist of this code is that we create the blocks dynamically, as many as will fit, and then store them in an array for future reference. +The \c initBoard function will be hooked up to the new game button soon, and should be fairly straight forward. + +The \c createBlock function is a lot bigger, and I'll explain it block by block. +First we ensure that the component has been constructed. QML elements, including composite ones like the \c Block.qml +that we've written, are never created directly in script. While there is a function to parse and create an arbitrary QML string, +in the case where you are repeatedly creating the sme item you will want to use the \c createComponent function. \c createComponent is +a built-in function in the declarative ECMAScript, and returns a component object. +A component object prepares and stores a QML element (usually a composite element) for easy and efficient use. +When the component is ready, you can create a new instance of the loaded QML with the \c createObject method. +If the component is loaded remotely (over HTTP for example) then you will have to wait for the component to finish loading +before calling \c createObject. Since we don't wait here (the waiting is a syncronous, the component object has a signal to tell +you when it's done) this code will only work if the block QML is a local file. + +As we aren't waiting for he component, the next block of code creates a game block with \c{component.createObject}. +Since there could be an error in the QML file you are trying to load, success is not guaranteed. +The first bit of error checkign code comes right after \c{createObject()}, to ensure that the object loaded correctly. +If it did not load correctly the function returns false, but we don't have that hooked up to the main UI to indicate +that something has gone wrong. Instead we print out error messages to the console, because an error here means an invalid +QML file and should only happen while you are developing and testing the UI. + +Next we start to set up our dynamically created block. +Because the \c{Block.qml} file is generic it needs to be placed in the main scene, and in the right place. +This is why \c parent, \c x, \c y, \c width and \c height are set. We then store it in the board array for later use. + +Finally, we have some more error handling. You can only call \c{createObject} if the component has loaded. +If it has not loaded, either it is still loading or there was an error loading (such as a missing file). +Since we don't request remote files the problem is likely to be a missing or misplaced file. +Again we print this to the console to aid debugging. You now have the code to create a field of blocks dynamically, like below: \image declarative-adv-tutorial2.png -To hook this code up to the 'New Game' button, you alter it as below: +To hook this code up to the \e{New Game} button, you alter it as below: \snippet declarative/tutorials/samegame/samegame2/samegame.qml 1 -We have just replaced the 'onClicked: print("Implement me!")' with 'onClicked: initBoard()'. Note that in order to have the function available, you'll need to include the script in the main file, by adding a script element to it. +We have just replaced the \c{onClicked: print("Implement me!")} with \c{onClicked: initBoard()}. +Note that in order to have the function available, you'll need to include the script in the main file, +by adding a script element to it. \snippet declarative/tutorials/samegame/samegame2/samegame.qml 2 -With those two changes, and the script file, you are now dynamically creating a field of blocks you can play with. They don't do anything now though; the next chapter will add the game mechanics. +With those two changes, and the script file, you are now dynamically creating a field of blocks you can play with. +They don't do anything now though; the next chapter will add the game mechanics. [Previous: \l {advtutorial1}{Advanced Tutorial 1}] [\l {advtutorial.html}{Advanced Tutorial}] [Next: \l {advtutorial3}{Advanced Tutorial 3}] diff --git a/doc/src/declarative/advtutorial3.qdoc b/doc/src/declarative/advtutorial3.qdoc index 635054b..841e150 100644 --- a/doc/src/declarative/advtutorial3.qdoc +++ b/doc/src/declarative/advtutorial3.qdoc @@ -1,33 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + /*! \page advtutorial3.html \title Advanced Tutorial 3 - Implementing the Game Logic \target advtutorial3 -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 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. The main change was adding the following game logic functions: \list -\o function handleClick(x,y) -\o function floodFill(xIdx,yIdx,type) -\o function shuffleDown() -\o function victoryCheck() -\o function floodMoveCheck(xIdx, yIdx, type) +\o function \c{handleClick(x,y)} +\o function \c{floodFill(xIdx,yIdx,type)} +\o function \c{shuffleDown()} +\o function \c{victoryCheck()} +\o function \c{floodMoveCheck(xIdx, yIdx, type)} \endlist -As this is a tutorial about QML, not game design, these functions will not be discussed in detail. The game logic here was written in script, but it could have been written in C++ and had these functions exposed just as well (in fact, probably faster). The interfacing between these funcions and QML is of interest though. Of these functions, only handleClick and victoryCheck interface closely with the QML. Those functions are shown below (the rest are still in the code for this tutorial located at $QTDIR/examples/declarative/tutorials/samegame). +As this is a tutorial about QML, not game design, these functions will not be discussed in detail. The game logic here +was written in script, but it could have been written in C++ and had these functions exposed just as well (in fact, probably faster). +The interfacing between these funcions and QML is of interest though. Of these functions, only \c handleClick and \c victoryCheck +interface closely with the QML. Those functions are shown below (the rest are still in the code for this tutorial located at +\c{$QTDIR/examples/declarative/tutorials/samegame}). \snippet declarative/tutorials/samegame/samegame3/samegame.js 1 \snippet declarative/tutorials/samegame/samegame3/samegame.js 2 -You'll notice them referring to the 'gameCanvas' item. This is an item that has been added to the QML for easy interfacing. It is placed next to the background image and replaces the background as the item to create the blocks in. Its code is shown below: +You'll notice them referring to the \c gameCanvas item. This is an item that has been added to the QML for easy interfacing. +It is placed next to the background image and replaces the background as the item to create the blocks in. +Its code is shown below: \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 as the noe determining board size. +Since it needs to bind its size to a multiple of \c tileSize, \c 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 \c handleClick(), which deals with the input events. Should those events cause the player to score, +\c{gameCanvas.score} is updated. The score display text item has also been changed to bind its text property to \c{gamecanvas.score}. +Note that if score was a global variable in the \c{samegame.js} file yo ucould 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: +\c victoryCheck() mostly just updates score. But it also pops up a dialog saying \e {Game Over} when the game is over. +In this example we wanted a pure-QML, animated dialog, and since QML doesn't contain one, we wrote our own. +Below is the code for the \c Dialog element, note how it's designed so as to be quite usable imperatively from within the script file: \snippet declarative/tutorials/samegame/samegame3/Dialog.qml 0 @@ -35,9 +91,10 @@ And this is how it's used in the main QML file: \snippet declarative/tutorials/samegame/samegame3/samegame.qml 2 -Combined with the line of code in victoryCheck, this causes a dialog to appear when the game is over, informing the user of that fact. +Combined with the line of code in \c victoryCheck, this causes a dialog to appear when the game is over, informing the user of that fact. -We now have a working game! The blocks can be clicked, the player can score, and the game can end (and then you start a new one). Below is a screenshot of what has been accomplished so far: +We now have a working game! The blocks can be clicked, the player can score, and the game can end (and then you start a new one). +Below is a screenshot of what has been accomplished so far: \image declarative-adv-tutorial3.png @@ -49,7 +106,9 @@ And the code for the block: \snippet declarative/tutorials/samegame/samegame3/Block.qml 0 -The game works, but it's a little boring right now. Where's the smooth animated transitions? Where's the high scores? If you were a QML expert you could have written these in for the first iteration, but in this tutorial they've been saved until the next chapter - where your application becomes alive! +The game works, but it's a little boring right now. Where's the smooth animated transitions? Where's the high scores? +If you were a QML expert you could have written these in for the first iteration, but in this tutorial they've been saved +until the next chapter - where your application becomes alive! [Previous: \l {advtutorial2}{Advanced Tutorial 2}] [\l {advtutorial.html}{Advanced Tutorial}] [Next: \l {advtutorial4}{Advanced Tutorial 4}] diff --git a/doc/src/declarative/advtutorial4.qdoc b/doc/src/declarative/advtutorial4.qdoc index 291d2f2..514c11a 100644 --- a/doc/src/declarative/advtutorial4.qdoc +++ b/doc/src/declarative/advtutorial4.qdoc @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + /*! \page advtutorial4.html \title Advanced Tutorial 4 - Finishing Touches @@ -5,11 +46,19 @@ Now we're going to do two things to liven the game up. Animate the blocks and add a web-based high score system. -If you compare the samegame3 directory with samegame4, you'll noticed that we've cleaned the directory structure up. We now have a lot of files, and so they've been split up into folders - the most notable one being a content folder which we've placed all the QML but the main file. +If you compare the \c samegame3 directory with \c samegame4, you'll noticed that we've cleaned the directory structure up. +We now have a lot of files, and so they've been split up into folders - the most notable one being a content folder +which we've placed all the QML but the main file. \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 \l Follow element. By having the script set \c targetX and \c targetY, instead of \c x +and \c y directly, we can set the \c x and \c y of the block to a follow. \l 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 \c Block.qml: \code property int targetX: 0 @@ -19,15 +68,25 @@ 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 \c{samegame.js} code, so that wherever it was setting the \c x or \c y it now sets \c targetX and \c 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 \c x in the \c createBlock function. The above snippet now becomes: \snippet declarative/tutorials/samegame/samegame4/content/BoomBlock.qml 1 -The next-most vital animation is a smooth exit. For this animation, we'll use a Behavior element. A Behavior is also a property value source, and it is much like SpringFollow except that it doesn't model the behavior of a spring. You specify how a Behavior transitions using the standard animations. As we want the blocks to smoothly fade in and out we'll set a Behavior on the block image's opacity, like so: +The next-most vital animation is a smooth exit. For this animation, we'll use a \l Behavior element. A Behavior is also a property +value source, and it is much like SpringFollow except that it doesn't model the behavior of a spring. You specify how a Behavior +transitions using the standard animations. As we want the blocks to smoothly fade in and out we'll set a Behavior on the block +image's opacity, like so: \snippet declarative/tutorials/samegame/samegame4/content/BoomBlock.qml 2 -Note that the 'opacity: 0' makes it start out transparent. We could set the opacity in the script file when we create the blocks, but instead we use states (as this is useful for the next animation we'll implement). The below snippet is set on the root element of Block.qml: +Note that the \c{opacity: 0} makes it start out transparent. We could set the opacity in the script file when we create the blocks, +but instead we use states (as this is useful for the next animation we'll implement). The below snippet is set on the root +element of \c{Block.qml}: \code property bool dying: false states: [ @@ -39,34 +98,52 @@ Note that the 'opacity: 0' makes it start out transparent. We could set the opac ] \endcode -Now it will automatically fade in, as we set spawned to true already when implementing the block movement animations. To fade out, we set 'dying' to true instead of setting opacity to 0 when a block is destroyed (in the floodFill function). +Now it will automatically fade in, as we set spawned to true already when implementing the block movement animations. +To fade out, we set 'dying' to true instead of setting opacity to 0 when a block is destroyed (in the \c floodFill function). -The least vital animations are a cool-looking particle effect when they get destroyed. First we create a Particles Element in the block, like so: +The least vital animations are a cool-looking particle effect when they get destroyed. First we create a \l Particles element in +the block, like so: \snippet declarative/tutorials/samegame/samegame4/content/BoomBlock.qml 3 -To fully understand this you'll want to look at the Particles element documentation, but it's important to note that count is set to zero. -We next extend the 'dying' state, which triggers the particles by setting the count to non-zero. The code for the states now look like this: +To fully understand this you'll want to look at the Particles element documentation, but it's important to note that count is set +to zero. +We next extend the 'dying' state, which triggers the particles by setting the count to non-zero. The code for the states now look +like this: \snippet declarative/tutorials/samegame/samegame4/content/BoomBlock.qml 4 -And now the game should be beautifully animated and smooth, with a subtle (or not-so-subtle) animation added for all of the player's actions. The end result is shown below: +And now the game should be beautifully animated and smooth, with a subtle (or not-so-subtle) animation added for all of the +player's actions. The end result is shown below: \image declarative-adv-tutorial4.gif \section2 Web-based High Scores -Another extension we might want for the game is some way of storing and retriveing high scores. In this tutorial we'll show you how to integrate a web enabled high score storage into your QML application. The implementation we've done is very simple - the high score data is posted to a php script running on a server somewhere, and that server then stores it and displays it to visitors. You could request an XML or QML file from that same server, which contained and displayed the scores, but that's beyond the scope of this tutorial. +Another extension we might want for the game is some way of storing and retriveing high scores. In this tutorial we'll show you +how to integrate a web enabled high score storage into your QML application. The implementation we've done is very +simple - the high score data is posted to a php script running on a server somewhere, and that server then stores it and +displays it to visitors. You could request an XML or QML file from that same server, which contained and displayed the scores, +but that's beyond the scope of this tutorial. -For better high score data, we want the name and time of the player. The time is obtained in the script fairly simply, but we have to ask the player for their name. We thus re-use the dialog QML file to pop up a dialog asking for the player's name (and if they exit this dialog without entering it they have a way to opt out of posting their high score). When the dialog is closed, if the player entered their name we can send the data to the web service in the followign snippet out of the script file: +For better high score data, we want the name and time of the player. The time is obtained in the script fairly simply, but we +have to ask the player for their name. We thus re-use the dialog QML file to pop up a dialog asking for the player's name (and +if they exit this dialog without entering it they have a way to opt out of posting their high score). When the dialog is closed, +if the player entered their name we can send the data to the web service in the followign snippet out of the script file: \snippet declarative/tutorials/samegame/samegame4/content/samegame.js 1 -This is the same XMLHttpRequest() as you'll find in browser javascript, and can be used in the same way to dynamically get XML or QML from the web service to display the high scores. We don't worry about the response here though, we just post the high score data to the web server. If it had returned a QML file (or a URL to a QML file) you could instantiate it in much the same way as you did the blocks. +This is the same \c XMLHttpRequest() as you'll find in browser javascript, and can be used in the same way to dynamically get XML +or QML from the web service to display the high scores. We don't worry about the response here though, we just post the high +score data to the web server. If it had returned a QML file (or a URL to a QML file) you could instantiate it in much the same +way as you did the blocks. -An alternate way to access and submit web-based data would be to use QML elements designed for this purpose - XmlListModel makes it very easy to fetch and display XML based data such as RSS in a QML application (see the Flickr demo for an example). +An alternate way to access and submit web-based data would be to use QML elements designed for this purpose - XmlListModel +makes it very easy to fetch and display XML based data such as RSS in a QML application (see the Flickr demo for an example). -By following this tutorial you've now ben shown how to write a fully functional application in QML, with the application logic written in a script file and with both many fluid animations and being web-enabled. Congratulations, you should now be skilled enough to write your own QML applications. +By following this tutorial you've now ben shown how to write a fully functional application in QML, with the application logic +written in a script file and with both many fluid animations and being web-enabled. Congratulations, you should now be skilled +enough to write your own QML applications. [Previous: \l {advtutorial3}{Advanced Tutorial 3}] [\l {advtutorial.html}{Advanced Tutorial}] */ diff --git a/doc/src/declarative/anchor-layout.qdoc b/doc/src/declarative/anchor-layout.qdoc index 8590aba..503b881 100644 --- a/doc/src/declarative/anchor-layout.qdoc +++ b/doc/src/declarative/anchor-layout.qdoc @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + /*! \page anchor-layout.html \target anchor-layout diff --git a/doc/src/declarative/animation.qdoc b/doc/src/declarative/animation.qdoc index 21263c1..caf78d3 100644 --- a/doc/src/declarative/animation.qdoc +++ b/doc/src/declarative/animation.qdoc @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + /*! \page qmlanimation.html \target qmlanimation diff --git a/doc/src/declarative/basictypes.qdoc b/doc/src/declarative/basictypes.qdoc index 6feb91b..80ec211 100644 --- a/doc/src/declarative/basictypes.qdoc +++ b/doc/src/declarative/basictypes.qdoc @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + /*! \page basicqmltypes.html \title Common QML Types diff --git a/doc/src/declarative/binding.qdoc b/doc/src/declarative/binding.qdoc index 99f2853..4f9bdc8 100644 --- a/doc/src/declarative/binding.qdoc +++ b/doc/src/declarative/binding.qdoc @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + /*! \page binding.html \title Data Binding in QML diff --git a/doc/src/declarative/cppitem.qdoc b/doc/src/declarative/cppitem.qdoc index 38da0fb..c5ef4c4 100644 --- a/doc/src/declarative/cppitem.qdoc +++ b/doc/src/declarative/cppitem.qdoc @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + /*! \page cppitem.html \target cppitem diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc index 1fe4892..cb30a6e 100644 --- a/doc/src/declarative/elements.qdoc +++ b/doc/src/declarative/elements.qdoc @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + /*! \page elements.html \target elements diff --git a/doc/src/declarative/examples.qdoc b/doc/src/declarative/examples.qdoc index 49a825a..5408098 100644 --- a/doc/src/declarative/examples.qdoc +++ b/doc/src/declarative/examples.qdoc @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + /*! \page qmlexamples.html \target qmlexamples @@ -14,7 +55,11 @@ There are several illustrative QML examples available. From your build directory, \code - bin/qmlviewer $QT_SOURCE_DIR/demos/declarative/flickr/flickr.qml + bin/qmlviewer $QT_SOURCE_DIR/demos/declarative/flickr/flickr-desktop.qml +\endcode +or +\code + bin/qmlviewer $QT_SOURCE_DIR/demos/declarative/samegame/samegame.qml \endcode Many other simple examples can be found under the \c examples/declarative sub diff --git a/doc/src/declarative/focus.qdoc b/doc/src/declarative/focus.qdoc index 14bebb1..c92632b 100644 --- a/doc/src/declarative/focus.qdoc +++ b/doc/src/declarative/focus.qdoc @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + /*! \target qmlfocus \page qmlfocus.html diff --git a/doc/src/declarative/measuring-performance.qdoc b/doc/src/declarative/measuring-performance.qdoc index 8c95422..01e7b03 100644 --- a/doc/src/declarative/measuring-performance.qdoc +++ b/doc/src/declarative/measuring-performance.qdoc @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + /*! \page optimizing-performance.html \target optimizing-performance diff --git a/doc/src/declarative/modules.qdoc b/doc/src/declarative/modules.qdoc index 7c67f60..3a6495d 100644 --- a/doc/src/declarative/modules.qdoc +++ b/doc/src/declarative/modules.qdoc @@ -1,4 +1,45 @@ -/*! +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! \target qmlmodules \page qmlmodules.html \title Modules diff --git a/doc/src/declarative/qmlforcpp.qdoc b/doc/src/declarative/qmlforcpp.qdoc index 697ea59..5378571 100644 --- a/doc/src/declarative/qmlforcpp.qdoc +++ b/doc/src/declarative/qmlforcpp.qdoc @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + /*! \page qmlforcpp.html \target qmlforcpp diff --git a/doc/src/declarative/qmlformat.qdoc b/doc/src/declarative/qmlformat.qdoc index 43eff05..be1afa4 100644 --- a/doc/src/declarative/qmlformat.qdoc +++ b/doc/src/declarative/qmlformat.qdoc @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + /*! \page qmlformat.html \title QML Format Reference diff --git a/doc/src/declarative/qmlintro.qdoc b/doc/src/declarative/qmlintro.qdoc index 56cc804..767cdd0 100644 --- a/doc/src/declarative/qmlintro.qdoc +++ b/doc/src/declarative/qmlintro.qdoc @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + /*! \page qmlintroduction.html \title Introduction to the QML language diff --git a/doc/src/declarative/qmlmodels.qdoc b/doc/src/declarative/qmlmodels.qdoc index 4712de1..eca81cd 100644 --- a/doc/src/declarative/qmlmodels.qdoc +++ b/doc/src/declarative/qmlmodels.qdoc @@ -1,4 +1,45 @@ -/*! +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! \page qmlmodels.html \target qmlmodels \title Data Models diff --git a/doc/src/declarative/qmlreference.qdoc b/doc/src/declarative/qmlreference.qdoc index b26fc64..1498189 100644 --- a/doc/src/declarative/qmlreference.qdoc +++ b/doc/src/declarative/qmlreference.qdoc @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + /*! \page qmlreference.html \title QML Reference @@ -17,24 +58,27 @@ Getting Started: \list - \o \l {Introduction to the QML language} (in progress) - \o \l {tutorial}{Tutorial: 'Hello world!'} + \o \l {Introduction to the QML language} + \o \l {tutorial}{Tutorial: 'Hello World'} \o \l {tutorials-declarative-contacts.html}{Tutorial: 'Introduction to QML'} + \o \l {advtutorial.html}{Advanced Tutorial: 'Same Game'} \o \l {qmlexamples}{Examples} \endlist - Core Features: + Core QML Features: \list \o \l {binding}{Data Binding} - \o \l {anchor-layout}{Layout Anchors} + \o \l {qmlmodels}{Data Models} + \o \l {anchor-layout}{Anchor-based Layout} \o \l {qmlanimation}{Animation} - \o \l {components}{Components} \o \l {qmlmodules}{Modules} \o \l {qmlfocus}{Keyboard Focus} + \o \l {Extending types from QML} \endlist QML Reference: \list + \o \l {QML Format Reference} \o \l {elements}{QML Elements} \endlist */ diff --git a/doc/src/declarative/qtdeclarative.qdoc b/doc/src/declarative/qtdeclarative.qdoc index f94b9f8..1a13049 100644 --- a/doc/src/declarative/qtdeclarative.qdoc +++ b/doc/src/declarative/qtdeclarative.qdoc @@ -50,8 +50,8 @@ Qt Declarative is targetted at the sorts of user interface (and the sorts of hardware) in embedded devices such as phones, media players, and set-top boxes. It is also appropriate for highly custom desktop - user-interfaces, or special elements in more traditional desktop - user-interfaces. + user interfaces, or special elements in more traditional desktop + user interfaces. Building fluid applications is done declaratively, rather than procedurally. That is, you specify \e what the UI should look like and how it should behave @@ -62,10 +62,11 @@ Getting Started: \list - \o \l {qmlexamples}{Examples} + \o \l {Introduction to the QML language} \o \l {tutorial}{Tutorial: 'Hello World'} - \o \l {advtutorial.html}{Advanced Tutorial: 'Same Game'} \o \l {tutorials-declarative-contacts.html}{Tutorial: 'Introduction to QML'} + \o \l {advtutorial.html}{Advanced Tutorial: 'Same Game'} + \o \l {qmlexamples}{Examples} \o \l {qmlforcpp}{QML For C++ Programmers} \endlist @@ -73,7 +74,7 @@ \list \o \l {binding}{Data Binding} \o \l {qmlmodels}{Data Models} - \o \l {anchor-layout}{Layout Anchors} + \o \l {anchor-layout}{Anchor-based Layout} \o \l {qmlanimation}{Animation} \o \l {qmlmodules}{Modules} \o \l {qmlfocus}{Keyboard Focus} diff --git a/doc/src/declarative/qtprogrammers.qdoc b/doc/src/declarative/qtprogrammers.qdoc index 3b20539..00c2d48 100644 --- a/doc/src/declarative/qtprogrammers.qdoc +++ b/doc/src/declarative/qtprogrammers.qdoc @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + /*! INCOMPLETE diff --git a/examples/declarative/tutorials/samegame/samegame2/samegame.qml b/examples/declarative/tutorials/samegame/samegame2/samegame.qml index 78a3d83..63431b1 100644 --- a/examples/declarative/tutorials/samegame/samegame2/samegame.qml +++ b/examples/declarative/tutorials/samegame/samegame2/samegame.qml @@ -5,9 +5,9 @@ Rectangle { width: 490; height: 720 SystemPalette { id: activePalette; colorGroup: Qt.Active } - //![2] +//![2] Script { source: "samegame.js" } - //![2] +//![2] Item { width: parent.width; anchors.top: parent.top; anchors.bottom: ToolBar.top @@ -25,13 +25,13 @@ Rectangle { height: 32; width: parent.width anchors.bottom: Screen.bottom - //![1] +//![1] Button { id: btnA; text: "New Game"; onClicked: initBoard(); anchors.left: parent.left; anchors.leftMargin: 3 anchors.verticalCenter: parent.verticalCenter } - //![1] +//![1] Text { id: Score diff --git a/examples/declarative/tutorials/samegame/samegame3/samegame.qml b/examples/declarative/tutorials/samegame/samegame3/samegame.qml index a0883da..5b98f48 100644 --- a/examples/declarative/tutorials/samegame/samegame3/samegame.qml +++ b/examples/declarative/tutorials/samegame/samegame3/samegame.qml @@ -17,7 +17,7 @@ Rectangle { fillMode: "PreserveAspectCrop" } - //![1] +//![1] Item { id: gameCanvas property int score: 0 @@ -32,12 +32,12 @@ Rectangle { anchors.fill: parent; onClicked: handleClick(mouse.x,mouse.y); } } - //![1] +//![1] } - //![2] +//![2] Dialog { id: dialog; anchors.centerIn: parent; z: 21 } - //![2] +//![2] Rectangle { id: ToolBar -- cgit v0.12 From 15c31bb195d02e1bb489c1aff5f93f1cb829f51f Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 8 Oct 2009 16:05:02 +1000 Subject: Add url() for setUrl(). --- src/declarative/util/qmlview.cpp | 10 ++++++++++ src/declarative/util/qmlview.h | 1 + 2 files changed, 11 insertions(+) diff --git a/src/declarative/util/qmlview.cpp b/src/declarative/util/qmlview.cpp index f932e4a..14f8279 100644 --- a/src/declarative/util/qmlview.cpp +++ b/src/declarative/util/qmlview.cpp @@ -235,6 +235,16 @@ void QmlView::setUrl(const QUrl& url) } /*! + Returns the source URL, if set. + + \sa setUrl() + */ +QUrl QmlView::url() const +{ + return d->source; +} + +/*! Sets the source to the URL from the \a filename, and sets the QML string to \a qml. */ diff --git a/src/declarative/util/qmlview.h b/src/declarative/util/qmlview.h index b54101f..faf2564 100644 --- a/src/declarative/util/qmlview.h +++ b/src/declarative/util/qmlview.h @@ -70,6 +70,7 @@ public: virtual ~QmlView(); void setUrl(const QUrl&); + QUrl url() const; void setQml(const QString &qml, const QString &filename=QString()); QString qml() const; QmlEngine* engine(); -- cgit v0.12 From 75eba69aed3a9b73d29e91c1f5b5463654321bea Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Thu, 8 Oct 2009 16:05:07 +1000 Subject: make examples compile --- examples/webkit/fancybrowser/mainwindow.cpp | 2 +- examples/webkit/googlechat/main.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/webkit/fancybrowser/mainwindow.cpp b/examples/webkit/fancybrowser/mainwindow.cpp index 2adfa20..a3293b8 100644 --- a/examples/webkit/fancybrowser/mainwindow.cpp +++ b/examples/webkit/fancybrowser/mainwindow.cpp @@ -56,7 +56,7 @@ MainWindow::MainWindow() file.close(); //! [1] - QNetworkProxyFactory::setUseSystemConfigurationEnabled(true); + QNetworkProxyFactory::setUseSystemConfiguration(true); //! [2] view = new QWebView(this); diff --git a/examples/webkit/googlechat/main.cpp b/examples/webkit/googlechat/main.cpp index fd08114..6b5e11f 100644 --- a/examples/webkit/googlechat/main.cpp +++ b/examples/webkit/googlechat/main.cpp @@ -47,7 +47,7 @@ int main(int argc, char * argv[]) { QApplication app(argc, argv); - QNetworkProxyFactory::setUseSystemConfigurationEnabled(true); + QNetworkProxyFactory::setUseSystemConfiguration(true); GoogleChat *chat = new GoogleChat; chat->show(); -- cgit v0.12 From d3ccca2c493ea8149c93cb1f548a676d2d298939 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 8 Oct 2009 16:05:29 +1000 Subject: Update. --- tests/auto/declarative/anchors/data/anchors.qml | 88 ++++++++++++------------ tests/auto/declarative/anchors/data/illegal1.qml | 6 +- tests/auto/declarative/anchors/data/illegal2.qml | 2 +- tests/auto/declarative/anchors/data/illegal3.qml | 6 +- tests/auto/declarative/anchors/data/loop1.qml | 2 +- tests/auto/declarative/anchors/data/loop2.qml | 2 +- tests/auto/declarative/anchors/tst_anchors.cpp | 36 ++++++---- 7 files changed, 77 insertions(+), 65 deletions(-) diff --git a/tests/auto/declarative/anchors/data/anchors.qml b/tests/auto/declarative/anchors/data/anchors.qml index 122d440..377dd2d 100644 --- a/tests/auto/declarative/anchors/data/anchors.qml +++ b/tests/auto/declarative/anchors/data/anchors.qml @@ -1,116 +1,116 @@ import Qt 4.6 -Rect { +Rectangle { color: "white" width: 240 height: 320 - Rect { id: MasterRect; x: 26; width: 96; height: 20; color: "red" } - Rect { - id: Rect1 + Rectangle { id: MasterRect; objectName: "MasterRect"; x: 26; width: 96; height: 20; color: "red" } + Rectangle { + id: Rect1; objectName: "Rect1" y: 20; width: 10; height: 10 anchors.left: MasterRect.left } - Rect { - id: Rect2 + Rectangle { + id: Rect2; objectName: "Rect2" y: 20; width: 10; height: 10 anchors.left: MasterRect.right } - Rect { - id: Rect3 + Rectangle { + id: Rect3; objectName: "Rect3" y: 20; width: 10; height: 10 anchors.left: MasterRect.horizontalCenter } - Rect { - id: Rect4 + Rectangle { + id: Rect4; objectName: "Rect4" y: 30; width: 10; height: 10 anchors.right: MasterRect.left } - Rect { - id: Rect5 + Rectangle { + id: Rect5; objectName: "Rect5" y: 30; width: 10; height: 10 anchors.right: MasterRect.right } - Rect { - id: Rect6 + Rectangle { + id: Rect6; objectName: "Rect6" y: 30; width: 10; height: 10 anchors.right: MasterRect.horizontalCenter } - Rect { - id: Rect7 + Rectangle { + id: Rect7; objectName: "Rect7" y: 50; width: 10; height: 10 anchors.left: parent.left } - Rect { - id: Rect8 + Rectangle { + id: Rect8; objectName: "Rect8" y: 50; width: 10; height: 10 anchors.left: parent.right } - Rect { - id: Rect9 + Rectangle { + id: Rect9; objectName: "Rect9" y: 50; width: 10; height: 10 anchors.left: parent.horizontalCenter } - Rect { - id: Rect10 + Rectangle { + id: Rect10; objectName: "Rect10" y: 60; width: 10; height: 10 anchors.right: parent.left } - Rect { - id: Rect11 + Rectangle { + id: Rect11; objectName: "Rect11" y: 60; width: 10; height: 10 anchors.right: parent.right } - Rect { - id: Rect12 + Rectangle { + id: Rect12; objectName: "Rect12" y: 60; width: 10; height: 10 anchors.right: parent.horizontalCenter } - Rect { - id: Rect13 + Rectangle { + id: Rect13; objectName: "Rect13" x: 200; width: 10; height: 10 anchors.top: MasterRect.bottom } - Rect { - id: Rect14 + Rectangle { + id: Rect14; objectName: "Rect14" width: 10; height: 10; color: "steelblue" anchors.verticalCenter: parent.verticalCenter } - Rect { - id: Rect15 + Rectangle { + id: Rect15; objectName: "Rect15" y: 200; height: 10 anchors.left: MasterRect.left anchors.right: MasterRect.right } - Rect { - id: Rect16 + Rectangle { + id: Rect16; objectName: "Rect16" y: 220; height: 10 anchors.left: MasterRect.left anchors.horizontalCenter: MasterRect.right } - Rect { - id: Rect17 + Rectangle { + id: Rect17; objectName: "Rect17" y: 240; height: 10 anchors.right: MasterRect.right anchors.horizontalCenter: MasterRect.left } - Rect { - id: Rect18 + Rectangle { + id: Rect18; objectName: "Rect18" x: 180; width: 10 anchors.top: MasterRect.bottom anchors.bottom: Rect12.top } - Rect { - id: Rect19 + Rectangle { + id: Rect19; objectName: "Rect19" y: 70; width: 10; height: 10 anchors.horizontalCenter: parent.horizontalCenter } - Rect { - id: Rect20 + Rectangle { + id: Rect20; objectName: "Rect20" y: 70; width: 10; height: 10 anchors.horizontalCenter: parent.right } - Rect { - id: Rect21 + Rectangle { + id: Rect21; objectName: "Rect21" y: 70; width: 10; height: 10 anchors.horizontalCenter: parent.left } diff --git a/tests/auto/declarative/anchors/data/illegal1.qml b/tests/auto/declarative/anchors/data/illegal1.qml index 1d23110..0a960d0 100644 --- a/tests/auto/declarative/anchors/data/illegal1.qml +++ b/tests/auto/declarative/anchors/data/illegal1.qml @@ -1,10 +1,10 @@ import Qt 4.6 -Rect { +Rectangle { id: rect width: 120; height: 200; color: "white" - Rect { id: TheRect; width: 100; height: 100 } - Rect { + Rectangle { id: TheRect; width: 100; height: 100 } + Rectangle { anchors.left: TheRect.left anchors.right: TheRect.right anchors.horizontalCenter: TheRect.horizontalCenter diff --git a/tests/auto/declarative/anchors/data/illegal2.qml b/tests/auto/declarative/anchors/data/illegal2.qml index 9f81b91..2497738 100644 --- a/tests/auto/declarative/anchors/data/illegal2.qml +++ b/tests/auto/declarative/anchors/data/illegal2.qml @@ -1,6 +1,6 @@ import Qt 4.6 -Rect { +Rectangle { id: rect width: 120; height: 200; color: "white" Text { id: Text1; text: "Hello" } diff --git a/tests/auto/declarative/anchors/data/illegal3.qml b/tests/auto/declarative/anchors/data/illegal3.qml index 4f07456..27b2e4d 100644 --- a/tests/auto/declarative/anchors/data/illegal3.qml +++ b/tests/auto/declarative/anchors/data/illegal3.qml @@ -1,12 +1,12 @@ import Qt 4.6 -Rect { +Rectangle { id: rect width: 120; height: 200; color: "white" Item { - Rect { id: TheRect; width: 100; height: 100 } + Rectangle { id: TheRect; width: 100; height: 100 } } - Rect { + Rectangle { anchors.left: TheRect.left } } diff --git a/tests/auto/declarative/anchors/data/loop1.qml b/tests/auto/declarative/anchors/data/loop1.qml index adc5a10..ef6b63d 100644 --- a/tests/auto/declarative/anchors/data/loop1.qml +++ b/tests/auto/declarative/anchors/data/loop1.qml @@ -1,6 +1,6 @@ import Qt 4.6 -Rect { +Rectangle { id: rect width: 120; height: 200; color: "white" Text { id: Text1; anchors.right: Text2.right; text: "Hello" } diff --git a/tests/auto/declarative/anchors/data/loop2.qml b/tests/auto/declarative/anchors/data/loop2.qml index a6856f8..2445a15 100644 --- a/tests/auto/declarative/anchors/data/loop2.qml +++ b/tests/auto/declarative/anchors/data/loop2.qml @@ -1,6 +1,6 @@ import Qt 4.6 -Rect { +Rectangle { id: container; width: 600; height: 600; diff --git a/tests/auto/declarative/anchors/tst_anchors.cpp b/tests/auto/declarative/anchors/tst_anchors.cpp index a8b119c..38b7fe8 100644 --- a/tests/auto/declarative/anchors/tst_anchors.cpp +++ b/tests/auto/declarative/anchors/tst_anchors.cpp @@ -3,6 +3,8 @@ #include #include #include +#include + class tst_anchors : public QObject { @@ -28,14 +30,17 @@ template T *tst_anchors::findItem(QFxItem *parent, const QString &objectName) { const QMetaObject &mo = T::staticMetaObject; - for (int i = 0; i < parent->QSimpleCanvasItem::children().count(); ++i) { - QFxItem *item = qobject_cast(parent->QSimpleCanvasItem::children().at(i)); - if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) { - return static_cast(item); + QList children = parent->childItems(); + for (int i = 0; i < children.count(); ++i) { + QFxItem *item = qobject_cast(children.at(i)->toGraphicsObject()); + if (item) { + if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) { + return static_cast(item); + } + item = findItem(item, objectName); + if (item) + return static_cast(item); } - item = findItem(item, objectName); - if (item) - return static_cast(item); } return 0; @@ -97,7 +102,10 @@ void tst_anchors::loops() view->setUrl(QUrl("file://" SRCDIR "/data/loop1.qml")); - QTest::ignoreMessage(QtWarningMsg, "QML QFxText (unknown location): Possible anchor loop detected on horizontal anchor. "); //x5 + QString expect = "QML QFxText (" + view->url().toString() + ":7:5" + ") Possible anchor loop detected on horizontal anchor. "; + QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); + QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); + QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); view->execute(); qApp->processEvents(); @@ -109,7 +117,8 @@ void tst_anchors::loops() view->setUrl(QUrl("file://" SRCDIR "/data/loop2.qml")); - QTest::ignoreMessage(QtWarningMsg, "QML QFxImage (unknown location): Possible anchor loop detected on horizontal anchor. "); //x3 + QString expect = "QML QFxImage (" + view->url().toString() + ":14:3" + ") Possible anchor loop detected on horizontal anchor. "; + QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); view->execute(); qApp->processEvents(); @@ -124,7 +133,8 @@ void tst_anchors::illegalSets() view->setUrl(QUrl("file://" SRCDIR "/data/illegal1.qml")); - QTest::ignoreMessage(QtWarningMsg, "QML QFxRect (unknown location): Can't specify left, right, and hcenter anchors. "); + QString expect = "QML QFxRect (" + view->url().toString() + ":7:5" + ") Can't specify left, right, and hcenter anchors. "; + QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); view->execute(); qApp->processEvents(); @@ -136,7 +146,8 @@ void tst_anchors::illegalSets() view->setUrl(QUrl("file://" SRCDIR "/data/illegal2.qml")); - QTest::ignoreMessage(QtWarningMsg, "QML QFxText (unknown location): Baseline anchor can't be used in conjunction with top, bottom, or vcenter anchors. "); + QString expect = "QML QFxText (" + view->url().toString() + ":7:5" + ") Baseline anchor can't be used in conjunction with top, bottom, or vcenter anchors. "; + QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); view->execute(); //qApp->processEvents(); @@ -148,7 +159,8 @@ void tst_anchors::illegalSets() view->setUrl(QUrl("file://" SRCDIR "/data/illegal3.qml")); - QTest::ignoreMessage(QtWarningMsg, "QML QFxRect (unknown location): Can't anchor to an item that isn't a parent or sibling. "); + QString expect = "QML QFxRect (" + view->url().toString() + ":9:5" + ") Can't anchor to an item that isn't a parent or sibling. "; + QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); view->execute(); //qApp->processEvents(); -- cgit v0.12 From 115232074a4becd5cf03974ac351331de1217f7d Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 8 Oct 2009 16:51:38 +1000 Subject: Remove spurious errors. Others seem real. --- tests/auto/declarative/listview/data/listview.qml | 2 +- tests/auto/declarative/listview/tst_listview.cpp | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/tests/auto/declarative/listview/data/listview.qml b/tests/auto/declarative/listview/data/listview.qml index 1a241eb..5083329 100644 --- a/tests/auto/declarative/listview/data/listview.qml +++ b/tests/auto/declarative/listview/data/listview.qml @@ -7,7 +7,7 @@ Rectangle { resources: [ Component { id: Delegate - Item { + Rectangle { id: wrapper objectName: "wrapper" height: 20 diff --git a/tests/auto/declarative/listview/tst_listview.cpp b/tests/auto/declarative/listview/tst_listview.cpp index 19d324d..2a5fa1c 100644 --- a/tests/auto/declarative/listview/tst_listview.cpp +++ b/tests/auto/declarative/listview/tst_listview.cpp @@ -33,7 +33,7 @@ private: template void removed(); QmlView *createView(const QString &filename); template - T *findItem(QFxItem *parent, const QString &id, int index=0); + T *findItem(QFxItem *parent, const QString &id, int index=-1); }; class TestModel : public QListModelInterface @@ -188,7 +188,7 @@ void tst_QFxListView::items() QFxItem *viewport = listview->viewport(); QVERIFY(viewport != 0); - QCOMPARE(viewport->childItems().count(), model.count()); // assumes all are visible + QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item for (int i = 0; i < model.count(); ++i) { QFxText *name = findItem(viewport, "textName", i); @@ -262,7 +262,7 @@ void tst_QFxListView::inserted() // let transitions settle. QTest::qWait(1000); - QCOMPARE(viewport->childItems().count(), model.count()); // assumes all are visible + QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item QFxText *name = findItem(viewport, "textName", 1); QVERIFY(name != 0); @@ -282,7 +282,7 @@ void tst_QFxListView::inserted() // let transitions settle. QTest::qWait(1000); - QCOMPARE(viewport->childItems().count(), model.count()); // assumes all are visible + QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item name = findItem(viewport, "textName", 0); QVERIFY(name != 0); @@ -338,6 +338,8 @@ void tst_QFxListView::removed() // Confirm items positioned correctly for (int i = 0; i < model.count() && i < viewport->childItems().count(); ++i) { QFxItem *item = findItem(viewport, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QVERIFY(item); QVERIFY(item->y() == i*20); } @@ -357,6 +359,8 @@ void tst_QFxListView::removed() // Confirm items positioned correctly for (int i = 0; i < model.count() && i < viewport->childItems().count(); ++i) { QFxItem *item = findItem(viewport, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QVERIFY(item); QCOMPARE(item->y(),i*20.0 + 20.0); } @@ -368,6 +372,8 @@ void tst_QFxListView::removed() // Confirm items positioned correctly for (int i = 0; i < model.count() && i < viewport->childItems().count(); ++i) { QFxItem *item = findItem(viewport, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QVERIFY(item); QCOMPARE(item->y(),i*20.0+20.0); } @@ -382,6 +388,8 @@ void tst_QFxListView::removed() // Confirm items positioned correctly for (int i = 2; i < 18; ++i) { QFxItem *item = findItem(viewport, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QVERIFY(item); QCOMPARE(item->y(),40+i*20.0); } @@ -392,6 +400,8 @@ void tst_QFxListView::removed() // Confirm items positioned correctly for (int i = 0; i < model.count() && i < viewport->childItems().count(); ++i) { QFxItem *item = findItem(viewport, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QVERIFY(item); QCOMPARE(item->y(),40+i*20.0); } @@ -452,7 +462,7 @@ QmlView *tst_QFxListView::createView(const QString &filename) } /* - Find an item with the specified id. If index is supplied then the + Find an item with the specified objectName. If index is supplied then the item must also evaluate the {index} expression equal to index */ template -- cgit v0.12 From 37d527f90a0ea430b4f97dd36a2048c89034ff97 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 8 Oct 2009 17:02:47 +1000 Subject: Update NumberFormatter now only goes from number to (formatted) text. --- .../numberformatter/tst_numberformatter.cpp | 49 +--------------------- 1 file changed, 2 insertions(+), 47 deletions(-) diff --git a/tests/auto/declarative/numberformatter/tst_numberformatter.cpp b/tests/auto/declarative/numberformatter/tst_numberformatter.cpp index 78ec347..412557f 100644 --- a/tests/auto/declarative/numberformatter/tst_numberformatter.cpp +++ b/tests/auto/declarative/numberformatter/tst_numberformatter.cpp @@ -18,15 +18,11 @@ public: void cleanupTestCase() {} private slots: - void number_data(); - void number(); - void text_data(); void text(); private: QStringList strings; - QList numbers; QStringList formats; QStringList texts; }; @@ -43,16 +39,6 @@ tst_numberformat::tst_numberformat() << "1.0" << "1.01"; - numbers << 100 - << 12345 - << 1234567 - << 0.123 - << 0.9999 - << 0.989 - << 1 - << 1.0 - << 1.01; - formats << "" << "0000" << "0000.00" @@ -151,37 +137,6 @@ tst_numberformat::tst_numberformat() << "texts.size()" << texts.size(); } -void tst_numberformat::number_data() -{ - QTest::addColumn("string"); - QTest::addColumn("number"); - - for (int i = 0; i < strings.size(); i++) - QTest::newRow(QString::number(i).toAscii()) << strings.at(i) << numbers.at(i); -} - -void tst_numberformat::number() -{ - // ### tests the conversion from string to float - QFETCH(QString, string); - QFETCH(float, number); - - QString componentStr = QString("import Qt 4.6\nNumberFormatter { number: \"") + string + QString("\" }"); - - QmlEngine engine; - QmlComponent formatterComponent(&engine, componentStr.toAscii(), QUrl("file://")); - if(formatterComponent.isError()) - qDebug() << formatterComponent.errors(); - QVERIFY(formatterComponent.isReady()); - QmlNumberFormatter *formatter = qobject_cast(formatterComponent.create()); - QVERIFY(formatterComponent.isReady()); - QVERIFY(formatter != 0); - QCOMPARE((float)formatter->number(), number); - //qDebug() << formatter->format() << formatter->text(); - QVERIFY(formatter->format().isEmpty()); - QVERIFY(formatter->text() == QString("%1").arg(number, -1, 'f', -1)); -} - void tst_numberformat::text_data() { QTest::addColumn("string"); @@ -205,10 +160,10 @@ void tst_numberformat::text() QFETCH(QString, format); QFETCH(QString, text); - QString componentStr = QString("import Qt 4.6\nNumberFormatter { number: \"") + string + QString("\"; format: \"") + format + QString("\" }"); + QString componentStr = QString("import Qt 4.6\nNumberFormatter { number: ") + string + QString("; format: \"") + format + QString("\" }"); QmlEngine engine; - QmlComponent formatterComponent(&engine, componentStr.toAscii(), QUrl("file://")); + QmlComponent formatterComponent(&engine, componentStr.toAscii(), QUrl("file:///")); if(formatterComponent.isError()) qDebug() << formatterComponent.errors(); QVERIFY(formatterComponent.isReady()); -- cgit v0.12 From 63e652ca7ec3b6983ebc8b0edd10199da862d53c Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 8 Oct 2009 17:13:23 +1000 Subject: Quieten expect net error --- .../declarative/qfxpixmapcache/tst_qfxpixmapcache.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/auto/declarative/qfxpixmapcache/tst_qfxpixmapcache.cpp b/tests/auto/declarative/qfxpixmapcache/tst_qfxpixmapcache.cpp index 4d3ad55..5e24831 100644 --- a/tests/auto/declarative/qfxpixmapcache/tst_qfxpixmapcache.cpp +++ b/tests/auto/declarative/qfxpixmapcache/tst_qfxpixmapcache.cpp @@ -65,12 +65,13 @@ void tst_qfxpixmapcache::single_data() QTest::addColumn("target"); QTest::addColumn("incache"); QTest::addColumn("exists"); + QTest::addColumn("neterror"); // File URLs are optimized - QTest::newRow("local") << thisfile.resolved(QUrl("data/exists.png")) << localfile_optimized << true; - QTest::newRow("local") << thisfile.resolved(QUrl("data/notexists.png")) << localfile_optimized << false; - QTest::newRow("remote") << QUrl("http://qt.nokia.com/logo.png") << false << true; - QTest::newRow("remote") << QUrl("http://qt.nokia.com/thereisnologo.png") << false << false; + QTest::newRow("local") << thisfile.resolved(QUrl("data/exists.png")) << localfile_optimized << true << false; + QTest::newRow("local") << thisfile.resolved(QUrl("data/notexists.png")) << localfile_optimized << false << false; + QTest::newRow("remote") << QUrl("http://qt.nokia.com/logo.png") << false << true << false; + QTest::newRow("remote") << QUrl("http://qt.nokia.com/thereisnologo.png") << false << false << true; } void tst_qfxpixmapcache::single() @@ -78,6 +79,14 @@ void tst_qfxpixmapcache::single() QFETCH(QUrl, target); QFETCH(bool, incache); QFETCH(bool, exists); + QFETCH(bool, neterror); + + if (neterror) { + QString expected = "Network error loading QUrl( \"" + +target.toString()+"\" ) \"Error downloading " + +target.toString()+" - server replied: Not Found\" "; + QTest::ignoreMessage(QtWarningMsg, expected.toLatin1()); + } QPixmap pixmap; QVERIFY(pixmap.width() <= 0); // Check Qt assumption -- cgit v0.12 From 5ca691eb57133cef3144967a70faa41147a8a37f Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 8 Oct 2009 17:15:48 +1000 Subject: Follow -> SpringFollow --- tests/auto/declarative/qmldom/tst_qmldom.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/declarative/qmldom/tst_qmldom.cpp b/tests/auto/declarative/qmldom/tst_qmldom.cpp index e1419cc..77c13c3 100644 --- a/tests/auto/declarative/qmldom/tst_qmldom.cpp +++ b/tests/auto/declarative/qmldom/tst_qmldom.cpp @@ -119,7 +119,7 @@ void tst_qmldom::loadComposite() void tst_qmldom::testValueSource() { QByteArray qml = "import Qt 4.6\n" - "Rectangle { height: Follow { spring: 1.4; damping: .15; source: Math.min(Math.max(-130, value*2.2 - 130), 133); }}"; + "Rectangle { height: SpringFollow { spring: 1.4; damping: .15; source: Math.min(Math.max(-130, value*2.2 - 130), 133); }}"; QmlEngine freshEngine; QmlDomDocument document; @@ -135,7 +135,7 @@ void tst_qmldom::testValueSource() QmlDomObject valueSourceObject = valueSource.object(); QVERIFY(valueSourceObject.isValid()); - QVERIFY(valueSourceObject.objectType() == "Qt/Follow"); + QVERIFY(valueSourceObject.objectType() == "Qt/SpringFollow"); const QmlDomValue springValue = valueSourceObject.property("spring").value(); QVERIFY(!springValue.isInvalid()); -- cgit v0.12 From 32e81daf19c5b4524302359a97dd3dc743edc912 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 8 Oct 2009 17:32:18 +1000 Subject: Update Repeater is now *after* items. --- tests/auto/declarative/repeater/tst_repeater.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/auto/declarative/repeater/tst_repeater.cpp b/tests/auto/declarative/repeater/tst_repeater.cpp index 1bb746b..68007a6 100644 --- a/tests/auto/declarative/repeater/tst_repeater.cpp +++ b/tests/auto/declarative/repeater/tst_repeater.cpp @@ -53,14 +53,18 @@ void tst_QFxRepeater::stringList() QCOMPARE(container->childItems().count(), data.count() + 3); + bool saw_repeater = false; for (int i = 0; i < container->childItems().count(); ++i) { if (i == 0) { QFxText *name = qobject_cast(container->childItems().at(i)); QVERIFY(name != 0); QCOMPARE(name->text(), QLatin1String("Zero")); - } else if (i == 1) { + } else if (i == container->childItems().count() - 2) { // The repeater itself + QFxRepeater *rep = qobject_cast(container->childItems().at(i)); + QCOMPARE(rep, repeater); + saw_repeater = true; continue; } else if (i == container->childItems().count() - 1) { QFxText *name = qobject_cast(container->childItems().at(i)); @@ -69,10 +73,10 @@ void tst_QFxRepeater::stringList() } else { QFxText *name = qobject_cast(container->childItems().at(i)); QVERIFY(name != 0); - QCOMPARE(name->text(), data.at(i-2)); + QCOMPARE(name->text(), data.at(i-1)); } - } + QVERIFY(saw_repeater); delete canvas; } -- cgit v0.12 From 896a5335efb375f67fef7cdff10c842046e61d3f Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 8 Oct 2009 17:34:22 +1000 Subject: Fix --- tests/auto/declarative/pathview/tst_pathview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/declarative/pathview/tst_pathview.cpp b/tests/auto/declarative/pathview/tst_pathview.cpp index e2da191..6e670bf 100644 --- a/tests/auto/declarative/pathview/tst_pathview.cpp +++ b/tests/auto/declarative/pathview/tst_pathview.cpp @@ -21,7 +21,7 @@ private slots: private: QmlView *createView(const QString &filename); template - T *findItem(QFxItem *parent, const QString &id, int index=0); + T *findItem(QFxItem *parent, const QString &id, int index=-1); }; class TestModel : public QListModelInterface -- cgit v0.12 From b416be48930ed52bad15fa220142f9228e82bcf8 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 8 Oct 2009 17:34:34 +1000 Subject: Update list of tests --- tests/auto/declarative/declarative.pro | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro index f2ddbb7..eef9da7 100644 --- a/tests/auto/declarative/declarative.pro +++ b/tests/auto/declarative/declarative.pro @@ -1,24 +1,32 @@ TEMPLATE = subdirs -SUBDIRS += datetimeformatter \ - numberformatter \ - qbindablemap \ +SUBDIRS += anchors \ + animations \ + datetimeformatter \ layouts \ listview \ + numberformatter \ pathview \ + qbindablemap \ + qfxloader \ + qfxpixmapcache \ qfxtext \ qfxtextedit \ - repeater \ - qmllanguage \ + qfxtextinput \ + qfxwebview \ + qmldom \ qmlecmascript \ - qmlmetaproperty \ + qmllanguage \ qmllist \ qmllistaccessor \ + qmlmetaproperty \ qmltimer \ - qfxloader \ - qfxwebview \ + repeater \ + sql \ states \ visual +SUBDIRS -= examples # Human-interactive + # Tests which should run in Pulse PULSE_TESTS = $$SUBDIRS PULSE_TESTS -= visual # All except 'visual' tests, allegedly too flaky -- cgit v0.12 From 6f5c3d1c6f9d3a826821d12139070e9772eae749 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 8 Oct 2009 18:30:19 +1000 Subject: Remove a bunch of unneeded semicolons. --- doc/src/declarative/qmlviewer.qdoc | 3 +++ src/declarative/debugger/qmldebug.h | 2 +- src/declarative/extra/qmlfontloader.cpp | 2 +- src/declarative/fx/qfxgridview.cpp | 2 +- src/declarative/fx/qfxitem.cpp | 10 ++++---- src/declarative/fx/qfxitem.h | 2 +- src/declarative/fx/qfxtextinput.h | 2 +- src/declarative/qml/qmlcomponentjs_p.h | 8 +++--- src/declarative/qml/qmlcontext.cpp | 2 +- src/declarative/qml/qmlvaluetype_p.h | 38 ++++++++++++++--------------- src/declarative/util/qmlpackage.cpp | 2 +- src/declarative/util/qmlpropertychanges.h | 2 +- src/declarative/util/qmlstateoperations.cpp | 2 +- 13 files changed, 40 insertions(+), 37 deletions(-) diff --git a/doc/src/declarative/qmlviewer.qdoc b/doc/src/declarative/qmlviewer.qdoc index 8228737..f153df2 100644 --- a/doc/src/declarative/qmlviewer.qdoc +++ b/doc/src/declarative/qmlviewer.qdoc @@ -49,6 +49,9 @@ toolkit. The \c qmlviewer reads a declarative user interface definition (\c .qml) file and displays the user interface it describes. + qmlviewer is a development tool. It is not intended to be + installed in a production environment. + \section1 Options When run with the \c -help option, qmlviewer shows available options. diff --git a/src/declarative/debugger/qmldebug.h b/src/declarative/debugger/qmldebug.h index 9fd5fae..681ee08 100644 --- a/src/declarative/debugger/qmldebug.h +++ b/src/declarative/debugger/qmldebug.h @@ -46,7 +46,7 @@ public: QObject *parent = 0); private: - Q_DECLARE_PRIVATE(QmlEngineDebug); + Q_DECLARE_PRIVATE(QmlEngineDebug) }; class Q_DECLARATIVE_EXPORT QmlDebugWatch : public QObject diff --git a/src/declarative/extra/qmlfontloader.cpp b/src/declarative/extra/qmlfontloader.cpp index 4497384..66c8567 100644 --- a/src/declarative/extra/qmlfontloader.cpp +++ b/src/declarative/extra/qmlfontloader.cpp @@ -54,7 +54,7 @@ QT_BEGIN_NAMESPACE class QmlFontLoaderPrivate : public QObjectPrivate { - Q_DECLARE_PUBLIC(QmlFontLoader); + Q_DECLARE_PUBLIC(QmlFontLoader) public: QmlFontLoaderPrivate() : reply(0), status(QmlFontLoader::Null) {} diff --git a/src/declarative/fx/qfxgridview.cpp b/src/declarative/fx/qfxgridview.cpp index 9aa1198..a8b27f4 100644 --- a/src/declarative/fx/qfxgridview.cpp +++ b/src/declarative/fx/qfxgridview.cpp @@ -145,7 +145,7 @@ public: class QFxGridViewPrivate : public QFxFlickablePrivate { - Q_DECLARE_PUBLIC(QFxGridView); + Q_DECLARE_PUBLIC(QFxGridView) public: QFxGridViewPrivate() diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 4d31aaa..d6534a1 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -408,12 +408,12 @@ public: class QFxKeyNavigationAttached : public QObject, public QFxItemKeyFilter { Q_OBJECT - Q_DECLARE_PRIVATE(QFxKeyNavigationAttached); + Q_DECLARE_PRIVATE(QFxKeyNavigationAttached) - Q_PROPERTY(QFxItem *left READ left WRITE setLeft NOTIFY changed); - Q_PROPERTY(QFxItem *right READ right WRITE setRight NOTIFY changed); - Q_PROPERTY(QFxItem *up READ up WRITE setUp NOTIFY changed); - Q_PROPERTY(QFxItem *down READ down WRITE setDown NOTIFY changed); + Q_PROPERTY(QFxItem *left READ left WRITE setLeft NOTIFY changed) + Q_PROPERTY(QFxItem *right READ right WRITE setRight NOTIFY changed) + Q_PROPERTY(QFxItem *up READ up WRITE setUp NOTIFY changed) + Q_PROPERTY(QFxItem *down READ down WRITE setDown NOTIFY changed) public: QFxKeyNavigationAttached(QObject * = 0); diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index 30c522f..bde0c9e 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -93,7 +93,7 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QGraphicsObject, public QmlParserSta Q_PROPERTY(QmlList* transform READ transform DESIGNABLE false FINAL) Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin) Q_PROPERTY(bool smooth READ smoothTransform WRITE setSmoothTransform) - Q_PROPERTY(QGraphicsEffect *effect READ graphicsEffect WRITE setGraphicsEffect); + Q_PROPERTY(QGraphicsEffect *effect READ graphicsEffect WRITE setGraphicsEffect) Q_ENUMS(TransformOrigin) Q_CLASSINFO("DefaultProperty", "data") diff --git a/src/declarative/fx/qfxtextinput.h b/src/declarative/fx/qfxtextinput.h index b1e8b14..d5d0450 100644 --- a/src/declarative/fx/qfxtextinput.h +++ b/src/declarative/fx/qfxtextinput.h @@ -193,7 +193,7 @@ private Q_SLOTS: void updateRect(const QRect &r = QRect()); private: - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QFxTextInput); + Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QFxTextInput) }; QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlcomponentjs_p.h b/src/declarative/qml/qmlcomponentjs_p.h index cee3035..0f56766 100644 --- a/src/declarative/qml/qmlcomponentjs_p.h +++ b/src/declarative/qml/qmlcomponentjs_p.h @@ -73,10 +73,10 @@ class Q_DECLARATIVE_EXPORT QmlComponentJS : public QmlComponent public: QmlComponentJS(QmlEngine *, const QUrl &url, QObject *parent = 0); QmlComponentJS(QmlEngine *, QObject *parent=0); - Q_PROPERTY(bool isNull READ isNull NOTIFY isNullChanged); - Q_PROPERTY(bool isReady READ isReady NOTIFY isReadyChanged); - Q_PROPERTY(bool isError READ isError NOTIFY isErrorChanged); - Q_PROPERTY(bool isLoading READ isLoading NOTIFY isLoadingChanged); + Q_PROPERTY(bool isNull READ isNull NOTIFY isNullChanged) + Q_PROPERTY(bool isReady READ isReady NOTIFY isReadyChanged) + Q_PROPERTY(bool isError READ isError NOTIFY isErrorChanged) + Q_PROPERTY(bool isLoading READ isLoading NOTIFY isLoadingChanged) Q_INVOKABLE QScriptValue createObject(); Q_INVOKABLE QString errorsString() const; diff --git a/src/declarative/qml/qmlcontext.cpp b/src/declarative/qml/qmlcontext.cpp index 97ab375..0632ef7 100644 --- a/src/declarative/qml/qmlcontext.cpp +++ b/src/declarative/qml/qmlcontext.cpp @@ -168,7 +168,7 @@ void QmlContextPrivate::addDefaultObject(QObject *object, Priority priority) \code class MyDataSet : ... { ... - Q_PROPERTY(QAbstractItemModel *myModel READ model NOTIFY modelChanged); + Q_PROPERTY(QAbstractItemModel *myModel READ model NOTIFY modelChanged) ... }; diff --git a/src/declarative/qml/qmlvaluetype_p.h b/src/declarative/qml/qmlvaluetype_p.h index a56feec..da5e972 100644 --- a/src/declarative/qml/qmlvaluetype_p.h +++ b/src/declarative/qml/qmlvaluetype_p.h @@ -85,8 +85,8 @@ public: class QmlPointFValueType : public QmlValueType { - Q_PROPERTY(qreal x READ x WRITE setX); - Q_PROPERTY(qreal y READ y WRITE setY); + Q_PROPERTY(qreal x READ x WRITE setX) + Q_PROPERTY(qreal y READ y WRITE setY) Q_OBJECT public: QmlPointFValueType(QObject *parent = 0); @@ -107,8 +107,8 @@ private: class QmlPointValueType : public QmlValueType { - Q_PROPERTY(int x READ x WRITE setX); - Q_PROPERTY(int y READ y WRITE setY); + Q_PROPERTY(int x READ x WRITE setX) + Q_PROPERTY(int y READ y WRITE setY) Q_OBJECT public: QmlPointValueType(QObject *parent = 0); @@ -129,8 +129,8 @@ private: class QmlSizeFValueType : public QmlValueType { - Q_PROPERTY(qreal width READ width WRITE setWidth); - Q_PROPERTY(qreal height READ height WRITE setHeight); + Q_PROPERTY(qreal width READ width WRITE setWidth) + Q_PROPERTY(qreal height READ height WRITE setHeight) Q_OBJECT public: QmlSizeFValueType(QObject *parent = 0); @@ -151,8 +151,8 @@ private: class QmlSizeValueType : public QmlValueType { - Q_PROPERTY(int width READ width WRITE setWidth); - Q_PROPERTY(int height READ height WRITE setHeight); + Q_PROPERTY(int width READ width WRITE setWidth) + Q_PROPERTY(int height READ height WRITE setHeight) Q_OBJECT public: QmlSizeValueType(QObject *parent = 0); @@ -173,10 +173,10 @@ private: class QmlRectFValueType : public QmlValueType { - Q_PROPERTY(qreal x READ x WRITE setX); - Q_PROPERTY(qreal y READ y WRITE setY); - Q_PROPERTY(qreal width READ width WRITE setWidth); - Q_PROPERTY(qreal height READ height WRITE setHeight); + Q_PROPERTY(qreal x READ x WRITE setX) + Q_PROPERTY(qreal y READ y WRITE setY) + Q_PROPERTY(qreal width READ width WRITE setWidth) + Q_PROPERTY(qreal height READ height WRITE setHeight) Q_OBJECT public: QmlRectFValueType(QObject *parent = 0); @@ -202,10 +202,10 @@ private: class QmlRectValueType : public QmlValueType { - Q_PROPERTY(int x READ x WRITE setX); - Q_PROPERTY(int y READ y WRITE setY); - Q_PROPERTY(int width READ width WRITE setWidth); - Q_PROPERTY(int height READ height WRITE setHeight); + Q_PROPERTY(int x READ x WRITE setX) + Q_PROPERTY(int y READ y WRITE setY) + Q_PROPERTY(int width READ width WRITE setWidth) + Q_PROPERTY(int height READ height WRITE setHeight) Q_OBJECT public: QmlRectValueType(QObject *parent = 0); @@ -231,9 +231,9 @@ private: class QmlVector3DValueType : public QmlValueType { - Q_PROPERTY(qreal x READ x WRITE setX); - Q_PROPERTY(qreal y READ y WRITE setY); - Q_PROPERTY(qreal z READ z WRITE setZ); + Q_PROPERTY(qreal x READ x WRITE setX) + Q_PROPERTY(qreal y READ y WRITE setY) + Q_PROPERTY(qreal z READ z WRITE setZ) Q_OBJECT public: QmlVector3DValueType(QObject *parent = 0); diff --git a/src/declarative/util/qmlpackage.cpp b/src/declarative/util/qmlpackage.cpp index 8483080..912bb6b 100644 --- a/src/declarative/util/qmlpackage.cpp +++ b/src/declarative/util/qmlpackage.cpp @@ -59,7 +59,7 @@ public: QmlPackageAttached(QObject *parent); virtual ~QmlPackageAttached(); - Q_PROPERTY(QString name READ name WRITE setName); + Q_PROPERTY(QString name READ name WRITE setName) QString name() const; void setName(const QString &n); diff --git a/src/declarative/util/qmlpropertychanges.h b/src/declarative/util/qmlpropertychanges.h index 8d338f1..2931cdb 100644 --- a/src/declarative/util/qmlpropertychanges.h +++ b/src/declarative/util/qmlpropertychanges.h @@ -58,7 +58,7 @@ class Q_DECLARATIVE_EXPORT QmlPropertyChanges : public QmlStateOperation Q_PROPERTY(QObject *target READ object WRITE setObject) Q_PROPERTY(bool restoreEntryValues READ restoreEntryValues WRITE setRestoreEntryValues) - Q_PROPERTY(bool explicit READ isExplicit WRITE setIsExplicit); + Q_PROPERTY(bool explicit READ isExplicit WRITE setIsExplicit) public: QmlPropertyChanges(); ~QmlPropertyChanges(); diff --git a/src/declarative/util/qmlstateoperations.cpp b/src/declarative/util/qmlstateoperations.cpp index 921aa6c..716cec4 100644 --- a/src/declarative/util/qmlstateoperations.cpp +++ b/src/declarative/util/qmlstateoperations.cpp @@ -189,7 +189,7 @@ QmlStateOperation::ActionList QmlParentChange::actions() class AccessibleFxItem : public QFxItem { Q_OBJECT - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QFxItem); + Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QFxItem) public: int siblingIndex() { Q_D(QFxItem); -- cgit v0.12