From 03eae0610376bec9a3b85f8fb9abc0a789322e37 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 19 May 2010 08:10:25 +0200 Subject: Update old keyword in docs --- src/declarative/graphicsitems/qdeclarativelayoutitem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativelayoutitem.cpp b/src/declarative/graphicsitems/qdeclarativelayoutitem.cpp index 1bbdd97..c8ecbb6 100644 --- a/src/declarative/graphicsitems/qdeclarativelayoutitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativelayoutitem.cpp @@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE /*! \qmlclass LayoutItem QDeclarativeLayoutItem \since 4.7 - \brief The LayoutItem element allows you to place your Fluid UI elements inside a classical Qt layout. + \brief The LayoutItem element allows you to place your declarative UI elements inside a classical Qt layout. LayoutItem is a variant of Item with a couple of additional properties. These properties provide the size hints needed for items to work in conjunction with Qt Layouts. The Qt Layout will resize the LayoutItem as appropriate, -- cgit v0.12 From 38420b1f63162802ede4861faf6d34dfa956d486 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 19 May 2010 16:38:37 +0200 Subject: Fix dynamicscene example In all the renaming (presumably) the moon broke, now fixed. Also made it slightly smaller, to be friendlier to desktop systems with small screens (and the fixed size qtdemo) --- examples/declarative/toys/dynamicscene/dynamicscene.qml | 10 ++++++---- .../declarative/toys/dynamicscene/qml/GenericSceneItem.qml | 9 +++++++++ examples/declarative/toys/dynamicscene/qml/itemCreation.js | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 examples/declarative/toys/dynamicscene/qml/GenericSceneItem.qml diff --git a/examples/declarative/toys/dynamicscene/dynamicscene.qml b/examples/declarative/toys/dynamicscene/dynamicscene.qml index 52c7c1e..2aa15e5 100644 --- a/examples/declarative/toys/dynamicscene/dynamicscene.qml +++ b/examples/declarative/toys/dynamicscene/dynamicscene.qml @@ -8,7 +8,8 @@ Item { property int activeSuns: 0 //This is a desktop-sized example - width: 1024; height: 512 + width: 800; height: 480 + //This is the message box that pops up when there's an error Rectangle { @@ -79,7 +80,7 @@ Item { Rectangle { id: toolbox - width: 480 + width: 380 color: activePalette.window anchors { right: parent.right; top: parent.top; bottom: parent.bottom } @@ -132,7 +133,7 @@ Item { Text { text: "Arbitrary QML:" } Rectangle { - width: 460; height: 240 + width: 360; height: 240 TextEdit { id: qmlText @@ -140,8 +141,9 @@ Item { readOnly: false focusOnPress: true font.pixelSize: 14 + wrapMode: TextEdit.WordWrap - text: "import Qt 4.7\nImage {\n id: smile\n x: 500 * Math.random()\n y: 200 * Math.random() \n source: 'images/face-smile.png'\n\n NumberAnimation on opacity { \n to: 0; duration: 1500\n }\n\n Component.onCompleted: smile.destroy(1500);\n}" + text: "import Qt 4.7\nImage {\n id: smile\n x: 360 * Math.random()\n y: 180 * Math.random() \n source: 'images/face-smile.png'\n NumberAnimation on opacity { \n to: 0; duration: 1500\n }\n Component.onCompleted: smile.destroy(1500);\n}" } } diff --git a/examples/declarative/toys/dynamicscene/qml/GenericSceneItem.qml b/examples/declarative/toys/dynamicscene/qml/GenericSceneItem.qml new file mode 100644 index 0000000..de096ad --- /dev/null +++ b/examples/declarative/toys/dynamicscene/qml/GenericSceneItem.qml @@ -0,0 +1,9 @@ +import Qt 4.7 + +Image { + property bool created: false + property string image + + source: image + +} diff --git a/examples/declarative/toys/dynamicscene/qml/itemCreation.js b/examples/declarative/toys/dynamicscene/qml/itemCreation.js index 59750f3..443c448 100644 --- a/examples/declarative/toys/dynamicscene/qml/itemCreation.js +++ b/examples/declarative/toys/dynamicscene/qml/itemCreation.js @@ -36,7 +36,7 @@ function createItem() { } else if (itemComponent.status == Component.Error) { draggedItem = null; console.log("error creating component"); - console.log(component.errorsString()); + console.log(itemComponent.errorsString()); } } -- cgit v0.12 From 1057b0a334c9ac7e7e1f3287935fad06de423108 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 20 May 2010 14:35:07 +1000 Subject: Add XmlListModel::errorString() --- src/declarative/util/qdeclarativexmllistmodel.cpp | 28 ++++++++++++++++++++-- src/declarative/util/qdeclarativexmllistmodel_p.h | 2 ++ .../tst_qdeclarativexmllistmodel.cpp | 9 +++++++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp index 4a374a5..cae1d3a 100644 --- a/src/declarative/util/qdeclarativexmllistmodel.cpp +++ b/src/declarative/util/qdeclarativexmllistmodel.cpp @@ -423,6 +423,7 @@ public: int highestRole; QNetworkReply *reply; QDeclarativeXmlListModel::Status status; + QString errorString; qreal progress; int queryId; QStringList keyRoleResultsCache; @@ -495,10 +496,11 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty \endcode - Then it could be used to create the following model: + A XmlListModel could create a model from this data, like this: \qml XmlListModel { + id: xmlModel source: "http://www.mysite.com/feed.xml" query: "/rss/channel/item" XmlRole { name: "title"; query: "title/string()" } @@ -511,6 +513,16 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty. + The model could be used in a ListView, like this: + + \qml + ListView { + width: 180; height: 300 + model: xmlModel + delegate: Text { title + " (" + pubDate + ")" } + } + \endqml + \section2 Using key XML roles @@ -722,7 +734,8 @@ void QDeclarativeXmlListModel::setNamespaceDeclarations(const QString &declarati \o XmlListModel.Null - No XML data has been set for this model. \o XmlListModel.Ready - The XML data has been loaded into the model. \o XmlListModel.Loading - The model is in the process of reading and loading XML data. - \o XmlListModel.Error - An error occurred while the model was loading. + \o XmlListModel.Error - An error occurred while the model was loading. See errorString() for details + about the error. \endlist \sa progress @@ -755,6 +768,12 @@ qreal QDeclarativeXmlListModel::progress() const return d->progress; } +QString QDeclarativeXmlListModel::errorString() const +{ + Q_D(const QDeclarativeXmlListModel); + return d->errorString; +} + void QDeclarativeXmlListModel::classBegin() { Q_D(QDeclarativeXmlListModel); @@ -807,6 +826,7 @@ void QDeclarativeXmlListModel::reload() d->queryId = globalXmlQuery()->doQuery(d->query, d->namespaces, d->xml.toUtf8(), &d->roleObjects, d->keyRoleResultsCache); d->progress = 1.0; d->status = Loading; + d->errorString.clear(); emit progressChanged(d->progress); emit statusChanged(d->status); return; @@ -816,6 +836,7 @@ void QDeclarativeXmlListModel::reload() d->queryId = XMLLISTMODEL_CLEAR_ID; d->progress = 1.0; d->status = Loading; + d->errorString.clear(); emit progressChanged(d->progress); emit statusChanged(d->status); QTimer::singleShot(0, this, SLOT(dataCleared())); @@ -824,6 +845,7 @@ void QDeclarativeXmlListModel::reload() d->progress = 0.0; d->status = Loading; + d->errorString.clear(); emit progressChanged(d->progress); emit statusChanged(d->status); @@ -854,6 +876,7 @@ void QDeclarativeXmlListModel::requestFinished() d->redirectCount = 0; if (d->reply->error() != QNetworkReply::NoError) { + d->errorString = d->reply->errorString(); disconnect(d->reply, 0, this, 0); d->reply->deleteLater(); d->reply = 0; @@ -919,6 +942,7 @@ void QDeclarativeXmlListModel::queryCompleted(const QDeclarativeXmlQueryResult & d->data = result.data; d->keyRoleResultsCache = result.keyRoleResultsCache; d->status = Ready; + d->errorString.clear(); d->queryId = -1; bool hasKeys = false; diff --git a/src/declarative/util/qdeclarativexmllistmodel_p.h b/src/declarative/util/qdeclarativexmllistmodel_p.h index 7b85476..7101c57 100644 --- a/src/declarative/util/qdeclarativexmllistmodel_p.h +++ b/src/declarative/util/qdeclarativexmllistmodel_p.h @@ -113,6 +113,8 @@ public: Status status() const; qreal progress() const; + Q_INVOKABLE QString errorString() const; + virtual void classBegin(); virtual void componentComplete(); diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp index 4173a44..7769979 100644 --- a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp +++ b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp @@ -268,10 +268,12 @@ void tst_qdeclarativexmllistmodel::xml() QDeclarativeXmlListModel *model = qobject_cast(component.create()); QSignalSpy spy(model, SIGNAL(statusChanged(QDeclarativeXmlListModel::Status))); + QVERIFY(model->errorString().isEmpty()); QCOMPARE(model->progress(), qreal(0.0)); QCOMPARE(model->status(), QDeclarativeXmlListModel::Loading); QTRY_COMPARE(spy.count(), 1); spy.clear(); QCOMPARE(model->status(), QDeclarativeXmlListModel::Ready); + QVERIFY(model->errorString().isEmpty()); QCOMPARE(model->progress(), qreal(1.0)); QCOMPARE(model->count(), 9); @@ -284,6 +286,7 @@ void tst_qdeclarativexmllistmodel::xml() QCOMPARE(model->status(), QDeclarativeXmlListModel::Loading); QTRY_COMPARE(spy.count(), 1); spy.clear(); QCOMPARE(model->status(), QDeclarativeXmlListModel::Ready); + QVERIFY(model->errorString().isEmpty()); QCOMPARE(model->count(), count); delete model; @@ -309,10 +312,12 @@ void tst_qdeclarativexmllistmodel::source() QDeclarativeXmlListModel *model = qobject_cast(component.create()); QSignalSpy spy(model, SIGNAL(statusChanged(QDeclarativeXmlListModel::Status))); + QVERIFY(model->errorString().isEmpty()); QCOMPARE(model->progress(), qreal(0.0)); QCOMPARE(model->status(), QDeclarativeXmlListModel::Loading); QTRY_COMPARE(spy.count(), 1); spy.clear(); QCOMPARE(model->status(), QDeclarativeXmlListModel::Ready); + QVERIFY(model->errorString().isEmpty()); QCOMPARE(model->progress(), qreal(1.0)); QCOMPARE(model->count(), 9); @@ -320,6 +325,7 @@ void tst_qdeclarativexmllistmodel::source() QCOMPARE(model->progress(), qreal(0.0)); QTRY_COMPARE(spy.count(), 1); spy.clear(); QCOMPARE(model->status(), QDeclarativeXmlListModel::Loading); + QVERIFY(model->errorString().isEmpty()); QEventLoop loop; QTimer timer; @@ -337,9 +343,12 @@ void tst_qdeclarativexmllistmodel::source() QCOMPARE(model->status(), status); QCOMPARE(model->count(), count); + if (status == QDeclarativeXmlListModel::Ready) QCOMPARE(model->progress(), qreal(1.0)); + QCOMPARE(model->errorString().isEmpty(), status == QDeclarativeXmlListModel::Ready); + delete model; } -- cgit v0.12 From 33f59e150e871a1a090f478bfdfa22dc175a9d6e Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 20 May 2010 14:40:21 +1000 Subject: Test e75088323ae15604139ddfd66b85cc3b8d43abeb Task-number: QTBUG-10820 --- tests/auto/declarative/qdeclarativeecmascript/data/compiled.qml | 4 ++++ .../declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp | 2 ++ 2 files changed, 6 insertions(+) diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/compiled.qml b/tests/auto/declarative/qdeclarativeecmascript/data/compiled.qml index a883e85..1655905 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/compiled.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/compiled.qml @@ -31,6 +31,8 @@ QtObject { property string test21: g property string test22: h property bool test23: i + property color test24: j + property color test25: k property real a: 4.5 property real b: 11.2 @@ -41,4 +43,6 @@ QtObject { property variant g: 6.7 property variant h: "!" property variant i: true + property string j: "#112233" + property string k: "#aa112233" } diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 4900fa2..9a8ad64 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -2090,6 +2090,8 @@ void tst_qdeclarativeecmascript::compiled() QCOMPARE(object->property("test21").toString(), QLatin1String("6.7")); QCOMPARE(object->property("test22").toString(), QLatin1String("!")); QCOMPARE(object->property("test23").toBool(), true); + QCOMPARE(qvariant_cast(object->property("test24")), QColor(0x11,0x22,0x33)); + QCOMPARE(qvariant_cast(object->property("test25")), QColor(0x11,0x22,0x33,0xAA)); delete object; } -- cgit v0.12 From 08a0ee7946d7c6575a32919cb147cdc34af7e3bc Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 20 May 2010 15:58:39 +1000 Subject: Remove warnings. Task-number: QTBUG-10816 --- src/declarative/qml/qdeclarativeinclude.cpp | 2 -- src/declarative/util/qdeclarativeanimation.cpp | 1 - 2 files changed, 3 deletions(-) diff --git a/src/declarative/qml/qdeclarativeinclude.cpp b/src/declarative/qml/qdeclarativeinclude.cpp index e37b68b..4cde54b 100644 --- a/src/declarative/qml/qdeclarativeinclude.cpp +++ b/src/declarative/qml/qdeclarativeinclude.cpp @@ -259,8 +259,6 @@ QScriptValue QDeclarativeInclude::worker_include(QScriptContext *ctxt, QScriptEn if (ctxt->argumentCount() == 0) return engine->undefinedValue(); - QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine); - QString urlString = ctxt->argument(0).toString(); QUrl url(ctxt->argument(0).toString()); if (url.isRelative()) { diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp index 1365cd7..de1c0cb 100644 --- a/src/declarative/util/qdeclarativeanimation.cpp +++ b/src/declarative/util/qdeclarativeanimation.cpp @@ -2543,7 +2543,6 @@ void QDeclarativeParentAnimation::transition(QDeclarativeStateActions &actions, QDeclarativeAction &yAction = pc->yIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction; QDeclarativeAction &sAction = pc->scaleIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction; QDeclarativeAction &rAction = pc->rotationIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction; - bool forward = (direction == QDeclarativeAbstractAnimation::Forward); QDeclarativeItem *target = pc->object(); QDeclarativeItem *targetParent = action.reverseEvent ? pc->originalParent() : pc->parent(); -- cgit v0.12 From a948c797e0c45c965ada005b34c274514a3c4d42 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 20 May 2010 17:14:36 +1000 Subject: Work around rendering bug in Rectangle. Task-number: QTBUG-10765 --- src/declarative/graphicsitems/qdeclarativerectangle.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativerectangle.cpp b/src/declarative/graphicsitems/qdeclarativerectangle.cpp index ccabbde..d098aa0 100644 --- a/src/declarative/graphicsitems/qdeclarativerectangle.cpp +++ b/src/declarative/graphicsitems/qdeclarativerectangle.cpp @@ -380,7 +380,9 @@ void QDeclarativeRectangle::generateBorderedRect() key += d->pen->color().name() % QString::number(d->pen->color().alpha(), 16); if (!QPixmapCache::find(key, &d->rectImage)) { - d->rectImage = QPixmap(pw*2 + 3, pw*2 + 3); + // Adding 5 here makes qDrawBorderPixmap() paint correctly with smooth: true + // See QTBUG-7999 and QTBUG-10765 for more details. + d->rectImage = QPixmap(pw*2 + 5, pw*2 + 5); d->rectImage.fill(Qt::transparent); QPainter p(&(d->rectImage)); p.setRenderHint(QPainter::Antialiasing); -- cgit v0.12 From 5d440e91c1b52769b5b0f4845748da2d8e2d1664 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 20 May 2010 10:48:38 +0200 Subject: Fix incorrect merge Didn't actually notice the name change of that function --- examples/declarative/toys/dynamicscene/qml/itemCreation.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/declarative/toys/dynamicscene/qml/itemCreation.js b/examples/declarative/toys/dynamicscene/qml/itemCreation.js index 443c448..305cf7a 100644 --- a/examples/declarative/toys/dynamicscene/qml/itemCreation.js +++ b/examples/declarative/toys/dynamicscene/qml/itemCreation.js @@ -36,7 +36,7 @@ function createItem() { } else if (itemComponent.status == Component.Error) { draggedItem = null; console.log("error creating component"); - console.log(itemComponent.errorsString()); + console.log(itemComponent.errorString()); } } -- cgit v0.12 From ee9c52d5dd38d99ea7d91cb612653f638e674ee3 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 20 May 2010 11:48:35 +0200 Subject: Update docs with correct property name --- src/declarative/util/qdeclarativelistmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp index 9a5c9de..7518eb7 100644 --- a/src/declarative/util/qdeclarativelistmodel.cpp +++ b/src/declarative/util/qdeclarativelistmodel.cpp @@ -162,7 +162,7 @@ QDeclarativeListModelParser::ListInstruction *QDeclarativeListModelParser::ListM spacing: 5 Text { text: "Attributes:" } Repeater { - dataSource: attributes + model: attributes Component { Text { text: description } } } } -- cgit v0.12 From dc5a426dba72eb1193f6cce913ece94d369d0fbe Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 20 May 2010 15:03:40 +0200 Subject: Some minor example fixes -dial moved to dial-example so the dirname is the same as the qml name -added rssnews to .pro so it can be installed -added some README files like the other dirs --- demos/declarative/declarative.pro | 2 + examples/declarative/README | 41 +++++++++++++++++ examples/declarative/toys/README | 37 +++++++++++++++ .../declarative/toys/dial-example/content/Dial.qml | 43 ++++++++++++++++++ .../toys/dial-example/content/background.png | Bin 0 -> 35876 bytes .../toys/dial-example/content/needle.png | Bin 0 -> 342 bytes .../toys/dial-example/content/needle_shadow.png | Bin 0 -> 632 bytes .../toys/dial-example/content/overlay.png | Bin 0 -> 3564 bytes .../declarative/toys/dial-example/dial-example.qml | 50 +++++++++++++++++++++ .../declarative/toys/dial-example/dial.qmlproject | 16 +++++++ examples/declarative/toys/dial/content/Dial.qml | 43 ------------------ .../declarative/toys/dial/content/background.png | Bin 35876 -> 0 bytes examples/declarative/toys/dial/content/needle.png | Bin 342 -> 0 bytes .../toys/dial/content/needle_shadow.png | Bin 632 -> 0 bytes examples/declarative/toys/dial/content/overlay.png | Bin 3564 -> 0 bytes examples/declarative/toys/dial/dial-example.qml | 50 --------------------- examples/declarative/toys/dial/dial.qmlproject | 16 ------- 17 files changed, 189 insertions(+), 109 deletions(-) create mode 100644 examples/declarative/README create mode 100644 examples/declarative/toys/README create mode 100644 examples/declarative/toys/dial-example/content/Dial.qml create mode 100644 examples/declarative/toys/dial-example/content/background.png create mode 100644 examples/declarative/toys/dial-example/content/needle.png create mode 100644 examples/declarative/toys/dial-example/content/needle_shadow.png create mode 100644 examples/declarative/toys/dial-example/content/overlay.png create mode 100644 examples/declarative/toys/dial-example/dial-example.qml create mode 100644 examples/declarative/toys/dial-example/dial.qmlproject delete mode 100644 examples/declarative/toys/dial/content/Dial.qml delete mode 100644 examples/declarative/toys/dial/content/background.png delete mode 100644 examples/declarative/toys/dial/content/needle.png delete mode 100644 examples/declarative/toys/dial/content/needle_shadow.png delete mode 100644 examples/declarative/toys/dial/content/overlay.png delete mode 100644 examples/declarative/toys/dial/dial-example.qml delete mode 100644 examples/declarative/toys/dial/dial.qmlproject diff --git a/demos/declarative/declarative.pro b/demos/declarative/declarative.pro index aa60db0..2963386 100644 --- a/demos/declarative/declarative.pro +++ b/demos/declarative/declarative.pro @@ -12,7 +12,9 @@ sources.files = \ samegame \ snake \ twitter \ + rssnews \ webbrowser + sources.path = $$[QT_INSTALL_DEMOS]/declarative INSTALLS += sources diff --git a/examples/declarative/README b/examples/declarative/README new file mode 100644 index 0000000..9e0f4c4 --- /dev/null +++ b/examples/declarative/README @@ -0,0 +1,41 @@ +The Qt Declarative module provides the ability to specify and implement +your UI declaratively, using the Qt Meta-Object Language(QML). This +language is very expressive and human readable, and can be used by +designers to actually implement their UI vision. QML UIs can integrate +with C++ code in many ways, including being loaded as a part of a C++ UI +and loading data models from C++ and interacting with them. + +The example launcher provided with Qt can be used to explore each of the +examples in this directory. But most can also be viewed directly with the +QML viewer utility, without requiring compilation. + +Documentation for these examples can be found via the Tutorial and Examples +link in the main Qt documentation. + + +Finding the Qt Examples and Demos launcher +========================================== + +On Windows: + +The launcher can be accessed via the Windows Start menu. Select the menu +entry entitled "Qt Examples and Demos" entry in the submenu containing +the Qt tools. + +On Mac OS X: + +For the binary distribution, the qtdemo executable is installed in the +/Developer/Applications/Qt directory. For the source distribution, it is +installed alongside the other Qt tools on the path specified when Qt is +configured. + +On Unix/Linux: + +The qtdemo executable is installed alongside the other Qt tools on the path +specified when Qt is configured. + +On all platforms: + +The source code for the launcher can be found in the demos/qtdemo directory +in the Qt package. This example is built at the same time as the Qt libraries, +tools, examples, and demonstrations. diff --git a/examples/declarative/toys/README b/examples/declarative/toys/README new file mode 100644 index 0000000..7fd7eb0 --- /dev/null +++ b/examples/declarative/toys/README @@ -0,0 +1,37 @@ +These pure QML examples create complete components to demonstrate +some of what can be easily done using just a few QML files. + +The example launcher provided with Qt can be used to explore each of the +examples in this directory. They can also be viewed directly with the +QML viewer utility, without requiring compilation. + +Documentation for these examples can be found via the Tutorial and Examples +link in the main Qt documentation. + + +Finding the Qt Examples and Demos launcher +========================================== + +On Windows: + +The launcher can be accessed via the Windows Start menu. Select the menu +entry entitled "Qt Examples and Demos" entry in the submenu containing +the Qt tools. + +On Mac OS X: + +For the binary distribution, the qtdemo executable is installed in the +/Developer/Applications/Qt directory. For the source distribution, it is +installed alongside the other Qt tools on the path specified when Qt is +configured. + +On Unix/Linux: + +The qtdemo executable is installed alongside the other Qt tools on the path +specified when Qt is configured. + +On all platforms: + +The source code for the launcher can be found in the demos/qtdemo directory +in the Qt package. This example is built at the same time as the Qt libraries, +tools, examples, and demonstrations. diff --git a/examples/declarative/toys/dial-example/content/Dial.qml b/examples/declarative/toys/dial-example/content/Dial.qml new file mode 100644 index 0000000..6f24801 --- /dev/null +++ b/examples/declarative/toys/dial-example/content/Dial.qml @@ -0,0 +1,43 @@ +import Qt 4.7 + +Item { + id: root + property real value : 0 + + width: 210; height: 210 + + Image { source: "background.png" } + +//! [needle_shadow] + Image { + x: 93 + y: 35 + source: "needle_shadow.png" + transform: Rotation { + origin.x: 11; origin.y: 67 + angle: needleRotation.angle + } + } +//! [needle_shadow] +//! [needle] + Image { + id: needle + x: 95; y: 33 + smooth: true + source: "needle.png" + transform: Rotation { + id: needleRotation + origin.x: 7; origin.y: 65 + angle: -130 + SpringFollow on angle { + spring: 1.4 + damping: .15 + to: Math.min(Math.max(-130, root.value*2.6 - 130), 133) + } + } + } +//! [needle] +//! [overlay] + Image { x: 21; y: 18; source: "overlay.png" } +//! [overlay] +} diff --git a/examples/declarative/toys/dial-example/content/background.png b/examples/declarative/toys/dial-example/content/background.png new file mode 100644 index 0000000..75d555d Binary files /dev/null and b/examples/declarative/toys/dial-example/content/background.png differ diff --git a/examples/declarative/toys/dial-example/content/needle.png b/examples/declarative/toys/dial-example/content/needle.png new file mode 100644 index 0000000..2d19f75 Binary files /dev/null and b/examples/declarative/toys/dial-example/content/needle.png differ diff --git a/examples/declarative/toys/dial-example/content/needle_shadow.png b/examples/declarative/toys/dial-example/content/needle_shadow.png new file mode 100644 index 0000000..8d8a928 Binary files /dev/null and b/examples/declarative/toys/dial-example/content/needle_shadow.png differ diff --git a/examples/declarative/toys/dial-example/content/overlay.png b/examples/declarative/toys/dial-example/content/overlay.png new file mode 100644 index 0000000..3860a7b Binary files /dev/null and b/examples/declarative/toys/dial-example/content/overlay.png differ diff --git a/examples/declarative/toys/dial-example/dial-example.qml b/examples/declarative/toys/dial-example/dial-example.qml new file mode 100644 index 0000000..900954f --- /dev/null +++ b/examples/declarative/toys/dial-example/dial-example.qml @@ -0,0 +1,50 @@ +import Qt 4.7 +import "content" + +//! [0] +Rectangle { + color: "#545454" + width: 300; height: 300 + + // Dial with a slider to adjust it + Dial { + id: dial + anchors.centerIn: parent + value: slider.x * 100 / (container.width - 34) + } + + Rectangle { + id: container + anchors { bottom: parent.bottom; left: parent.left + right: parent.right; leftMargin: 20; rightMargin: 20 + bottomMargin: 10 + } + height: 16 + + radius: 8 + opacity: 0.7 + smooth: true + gradient: Gradient { + GradientStop { position: 0.0; color: "gray" } + GradientStop { position: 1.0; color: "white" } + } + + Rectangle { + id: slider + x: 1; y: 1; width: 30; height: 14 + radius: 6 + smooth: true + gradient: Gradient { + GradientStop { position: 0.0; color: "#424242" } + GradientStop { position: 1.0; color: "black" } + } + + MouseArea { + anchors.fill: parent + drag.target: parent; drag.axis: Drag.XAxis + drag.minimumX: 2; drag.maximumX: container.width - 32 + } + } + } +} +//! [0] \ No newline at end of file diff --git a/examples/declarative/toys/dial-example/dial.qmlproject b/examples/declarative/toys/dial-example/dial.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/toys/dial-example/dial.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/toys/dial/content/Dial.qml b/examples/declarative/toys/dial/content/Dial.qml deleted file mode 100644 index 6f24801..0000000 --- a/examples/declarative/toys/dial/content/Dial.qml +++ /dev/null @@ -1,43 +0,0 @@ -import Qt 4.7 - -Item { - id: root - property real value : 0 - - width: 210; height: 210 - - Image { source: "background.png" } - -//! [needle_shadow] - Image { - x: 93 - y: 35 - source: "needle_shadow.png" - transform: Rotation { - origin.x: 11; origin.y: 67 - angle: needleRotation.angle - } - } -//! [needle_shadow] -//! [needle] - Image { - id: needle - x: 95; y: 33 - smooth: true - source: "needle.png" - transform: Rotation { - id: needleRotation - origin.x: 7; origin.y: 65 - angle: -130 - SpringFollow on angle { - spring: 1.4 - damping: .15 - to: Math.min(Math.max(-130, root.value*2.6 - 130), 133) - } - } - } -//! [needle] -//! [overlay] - Image { x: 21; y: 18; source: "overlay.png" } -//! [overlay] -} diff --git a/examples/declarative/toys/dial/content/background.png b/examples/declarative/toys/dial/content/background.png deleted file mode 100644 index 75d555d..0000000 Binary files a/examples/declarative/toys/dial/content/background.png and /dev/null differ diff --git a/examples/declarative/toys/dial/content/needle.png b/examples/declarative/toys/dial/content/needle.png deleted file mode 100644 index 2d19f75..0000000 Binary files a/examples/declarative/toys/dial/content/needle.png and /dev/null differ diff --git a/examples/declarative/toys/dial/content/needle_shadow.png b/examples/declarative/toys/dial/content/needle_shadow.png deleted file mode 100644 index 8d8a928..0000000 Binary files a/examples/declarative/toys/dial/content/needle_shadow.png and /dev/null differ diff --git a/examples/declarative/toys/dial/content/overlay.png b/examples/declarative/toys/dial/content/overlay.png deleted file mode 100644 index 3860a7b..0000000 Binary files a/examples/declarative/toys/dial/content/overlay.png and /dev/null differ diff --git a/examples/declarative/toys/dial/dial-example.qml b/examples/declarative/toys/dial/dial-example.qml deleted file mode 100644 index 900954f..0000000 --- a/examples/declarative/toys/dial/dial-example.qml +++ /dev/null @@ -1,50 +0,0 @@ -import Qt 4.7 -import "content" - -//! [0] -Rectangle { - color: "#545454" - width: 300; height: 300 - - // Dial with a slider to adjust it - Dial { - id: dial - anchors.centerIn: parent - value: slider.x * 100 / (container.width - 34) - } - - Rectangle { - id: container - anchors { bottom: parent.bottom; left: parent.left - right: parent.right; leftMargin: 20; rightMargin: 20 - bottomMargin: 10 - } - height: 16 - - radius: 8 - opacity: 0.7 - smooth: true - gradient: Gradient { - GradientStop { position: 0.0; color: "gray" } - GradientStop { position: 1.0; color: "white" } - } - - Rectangle { - id: slider - x: 1; y: 1; width: 30; height: 14 - radius: 6 - smooth: true - gradient: Gradient { - GradientStop { position: 0.0; color: "#424242" } - GradientStop { position: 1.0; color: "black" } - } - - MouseArea { - anchors.fill: parent - drag.target: parent; drag.axis: Drag.XAxis - drag.minimumX: 2; drag.maximumX: container.width - 32 - } - } - } -} -//! [0] \ No newline at end of file diff --git a/examples/declarative/toys/dial/dial.qmlproject b/examples/declarative/toys/dial/dial.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/toys/dial/dial.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} -- cgit v0.12 From 0a2ef85bc7c560f38f5ba591968ce49969893a1c Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 20 May 2010 19:23:19 +0200 Subject: Make dynamicscene example embeddeable in another graphics scene --- examples/declarative/toys/dynamicscene/qml/itemCreation.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/declarative/toys/dynamicscene/qml/itemCreation.js b/examples/declarative/toys/dynamicscene/qml/itemCreation.js index 305cf7a..e74f7b0 100644 --- a/examples/declarative/toys/dynamicscene/qml/itemCreation.js +++ b/examples/declarative/toys/dynamicscene/qml/itemCreation.js @@ -5,7 +5,7 @@ var posnInWindow; function startDrag(mouse) { - posnInWindow = paletteItem.mapToItem(null, 0, 0); + posnInWindow = paletteItem.mapToItem(window, 0, 0); startingMouse = { x: mouse.x, y: mouse.y } loadComponent(); } -- cgit v0.12