summaryrefslogtreecommitdiffstats
path: root/examples/declarative
diff options
context:
space:
mode:
Diffstat (limited to 'examples/declarative')
-rw-r--r--examples/declarative/animation/behaviors/behavior-example.qml2
-rw-r--r--examples/declarative/cppextensions/cppextensions.qmlproject2
-rw-r--r--examples/declarative/keyinteraction/focus/Core/GridMenu.qml7
-rw-r--r--examples/declarative/keyinteraction/focus/Core/ListViewDelegate.qml17
-rw-r--r--examples/declarative/keyinteraction/focus/Core/ListViews.qml4
-rw-r--r--examples/declarative/keyinteraction/focus/focus.qml5
-rw-r--r--examples/declarative/modelviews/abstractitemmodel/abstractitemmodel.pro8
-rw-r--r--examples/declarative/modelviews/abstractitemmodel/abstractitemmodel.qrc6
-rw-r--r--examples/declarative/modelviews/abstractitemmodel/main.cpp66
-rw-r--r--examples/declarative/modelviews/abstractitemmodel/model.cpp88
-rw-r--r--examples/declarative/modelviews/abstractitemmodel/model.h83
-rw-r--r--examples/declarative/modelviews/abstractitemmodel/view.qml51
-rw-r--r--examples/declarative/modelviews/objectlistmodel/dataobject.h4
-rw-r--r--examples/declarative/modelviews/objectlistmodel/main.cpp5
-rw-r--r--examples/declarative/modelviews/objectlistmodel/view.qml18
-rw-r--r--examples/declarative/modelviews/stringlistmodel/main.cpp5
-rw-r--r--examples/declarative/modelviews/stringlistmodel/view.qml16
-rw-r--r--examples/declarative/ui-components/progressbar/content/ProgressBar.qml2
-rw-r--r--examples/declarative/ui-components/searchbox/SearchBox.qml2
-rw-r--r--examples/declarative/ui-components/tabwidget/main.qml6
20 files changed, 356 insertions, 41 deletions
diff --git a/examples/declarative/animation/behaviors/behavior-example.qml b/examples/declarative/animation/behaviors/behavior-example.qml
index d187fbf..adefb9e 100644
--- a/examples/declarative/animation/behaviors/behavior-example.qml
+++ b/examples/declarative/animation/behaviors/behavior-example.qml
@@ -82,7 +82,7 @@ Rectangle {
property string text
- x: 62.5; y: 75; width: 75; height: 50
+ x: 62; y: 75; width: 75; height: 50
radius: 6
border.width: 4; border.color: "white"
color: "firebrick"
diff --git a/examples/declarative/cppextensions/cppextensions.qmlproject b/examples/declarative/cppextensions/cppextensions.qmlproject
index d4909f8..6b36284 100644
--- a/examples/declarative/cppextensions/cppextensions.qmlproject
+++ b/examples/declarative/cppextensions/cppextensions.qmlproject
@@ -12,5 +12,5 @@ Project {
directory: "."
}
/* List of plugin directories passed to QML runtime */
- // importPaths: [ " ../exampleplugin " ]
+ importPaths: [ "plugins" ]
}
diff --git a/examples/declarative/keyinteraction/focus/Core/GridMenu.qml b/examples/declarative/keyinteraction/focus/Core/GridMenu.qml
index d0b45f5..9a8d3f3 100644
--- a/examples/declarative/keyinteraction/focus/Core/GridMenu.qml
+++ b/examples/declarative/keyinteraction/focus/Core/GridMenu.qml
@@ -55,10 +55,11 @@ FocusScope {
GridView {
id: gridView
- x: 20; width: parent.width - 40; height: parent.height
+ anchors.fill: parent; anchors.leftMargin: 20; anchors.rightMargin: 20
cellWidth: 152; cellHeight: 152
focus: true
model: 12
+
KeyNavigation.down: listViews
KeyNavigation.left: contextMenu
@@ -70,9 +71,9 @@ FocusScope {
id: content
color: "transparent"
smooth: true
- anchors.centerIn: parent; width: container.width - 40; height: container.height - 40; radius: 10
+ anchors.fill: parent; anchors.margins: 20; radius: 10
- Rectangle { color: "#91AA9D"; x: 3; y: 3; width: parent.width - 6; height: parent.height - 6; radius: 8 }
+ Rectangle { color: "#91AA9D"; anchors.fill: parent; anchors.margins: 3; radius: 8; smooth: true }
Image { source: "images/qt-logo.png"; anchors.centerIn: parent; smooth: true }
}
diff --git a/examples/declarative/keyinteraction/focus/Core/ListViewDelegate.qml b/examples/declarative/keyinteraction/focus/Core/ListViewDelegate.qml
index fba9b05..cc13637 100644
--- a/examples/declarative/keyinteraction/focus/Core/ListViewDelegate.qml
+++ b/examples/declarative/keyinteraction/focus/Core/ListViewDelegate.qml
@@ -42,7 +42,7 @@ import Qt 4.7
Item {
id: container
- x: 5; width: ListView.view.width - 10; height: 60
+ width: ListView.view.width; height: 60; anchors.leftMargin: 10; anchors.rightMargin: 10
Rectangle {
id: content
@@ -51,11 +51,15 @@ Item {
smooth: true
radius: 10
- Rectangle { color: "#91AA9D"; x: 3; y: 3; width: parent.width - 6; height: parent.height - 6; radius: 8 }
- Text {
- text: "List element " + (index + 1); color: "#193441"; font.bold: false; anchors.centerIn: parent
- font.pixelSize: 14
- }
+ Rectangle { anchors.fill: parent; anchors.margins: 3; color: "#91AA9D"; smooth: true; radius: 8 }
+ }
+
+ Text {
+ id: label
+ anchors.centerIn: content
+ text: "List element " + (index + 1)
+ color: "#193441"
+ font.pixelSize: 14
}
MouseArea {
@@ -72,6 +76,7 @@ Item {
states: State {
name: "active"; when: container.focus == true
PropertyChanges { target: content; color: "#FCFFF5"; scale: 1.1 }
+ PropertyChanges { target: label; font.pixelSize: 16 }
}
transitions: Transition {
diff --git a/examples/declarative/keyinteraction/focus/Core/ListViews.qml b/examples/declarative/keyinteraction/focus/Core/ListViews.qml
index 670a3fa..6f9ceb4 100644
--- a/examples/declarative/keyinteraction/focus/Core/ListViews.qml
+++ b/examples/declarative/keyinteraction/focus/Core/ListViews.qml
@@ -60,7 +60,7 @@ FocusScope {
ListView {
id: list2
- y: wantsFocus ? 10 : 40; x: parent.width / 3; width: parent.width / 3; height: parent.height - 20
+ y: wantsFocus ? 10 : 40; x: parseInt(parent.width / 3); width: parent.width / 3; height: parent.height - 20
KeyNavigation.up: gridMenu; KeyNavigation.left: list1; KeyNavigation.right: list3
model: 10; cacheBuffer: 200
delegate: ListViewDelegate {}
@@ -72,7 +72,7 @@ FocusScope {
ListView {
id: list3
- y: wantsFocus ? 10 : 40; x: 2 * parent.width / 3; width: parent.width / 3; height: parent.height - 20
+ y: wantsFocus ? 10 : 40; x: parseInt(2 * parent.width / 3); width: parent.width / 3; height: parent.height - 20
KeyNavigation.up: gridMenu; KeyNavigation.left: list2
model: 10; cacheBuffer: 200
delegate: ListViewDelegate {}
diff --git a/examples/declarative/keyinteraction/focus/focus.qml b/examples/declarative/keyinteraction/focus/focus.qml
index 068ba1d..8b2af70 100644
--- a/examples/declarative/keyinteraction/focus/focus.qml
+++ b/examples/declarative/keyinteraction/focus/focus.qml
@@ -68,7 +68,8 @@ Rectangle {
Rectangle {
id: shade
- color: "black"; opacity: 0; anchors.fill: parent
+ anchors.fill: parent
+ color: "black"; opacity: 0
}
states: State {
@@ -88,7 +89,7 @@ Rectangle {
anchors.verticalCenter: parent.verticalCenter
MouseArea {
- anchors { fill: parent; leftMargin: -10; topMargin: -10; rightMargin: -10; bottomMargin: -10 }
+ anchors.fill: parent; anchors.margins: -10
onClicked: window.state = "contextMenuOpen"
}
}
diff --git a/examples/declarative/modelviews/abstractitemmodel/abstractitemmodel.pro b/examples/declarative/modelviews/abstractitemmodel/abstractitemmodel.pro
new file mode 100644
index 0000000..55e67f3
--- /dev/null
+++ b/examples/declarative/modelviews/abstractitemmodel/abstractitemmodel.pro
@@ -0,0 +1,8 @@
+TEMPLATE = app
+
+QT += declarative
+
+RESOURCES += abstractitemmodel.qrc
+
+HEADERS = model.h
+SOURCES = main.cpp model.cpp
diff --git a/examples/declarative/modelviews/abstractitemmodel/abstractitemmodel.qrc b/examples/declarative/modelviews/abstractitemmodel/abstractitemmodel.qrc
new file mode 100644
index 0000000..4ae861c
--- /dev/null
+++ b/examples/declarative/modelviews/abstractitemmodel/abstractitemmodel.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>view.qml</file>
+</qresource>
+</RCC>
+
diff --git a/examples/declarative/modelviews/abstractitemmodel/main.cpp b/examples/declarative/modelviews/abstractitemmodel/main.cpp
new file mode 100644
index 0000000..e869aba
--- /dev/null
+++ b/examples/declarative/modelviews/abstractitemmodel/main.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "model.h"
+#include <QDeclarativeContext>
+#include <QDeclarativeView>
+
+#include <QApplication>
+
+//![0]
+int main(int argc, char ** argv)
+{
+ QApplication app(argc, argv);
+
+ AnimalModel model;
+ model.addAnimal(Animal("Wolf", "Medium"));
+ model.addAnimal(Animal("Polar bear", "Large"));
+ model.addAnimal(Animal("Quoll", "Small"));
+
+ QDeclarativeView view;
+ QDeclarativeContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", &model);
+//![0]
+
+ view.setSource(QUrl("qrc:view.qml"));
+ view.show();
+
+ return app.exec();
+}
+
diff --git a/examples/declarative/modelviews/abstractitemmodel/model.cpp b/examples/declarative/modelviews/abstractitemmodel/model.cpp
new file mode 100644
index 0000000..d0e0971
--- /dev/null
+++ b/examples/declarative/modelviews/abstractitemmodel/model.cpp
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "model.h"
+
+Animal::Animal(const QString &type, const QString &size)
+ : m_type(type), m_size(size)
+{
+}
+
+QString Animal::type() const
+{
+ return m_type;
+}
+
+QString Animal::size() const
+{
+ return m_size;
+}
+
+//![0]
+AnimalModel::AnimalModel(QObject *parent)
+ : QAbstractListModel(parent)
+{
+ QHash<int, QByteArray> roles;
+ roles[TypeRole] = "type";
+ roles[SizeRole] = "size";
+ setRoleNames(roles);
+}
+//![0]
+
+void AnimalModel::addAnimal(const Animal &animal)
+{
+ m_animals << animal;
+}
+
+int AnimalModel::rowCount(const QModelIndex & parent) const {
+ return m_animals.count();
+}
+
+QVariant AnimalModel::data(const QModelIndex & index, int role) const {
+ if (index.row() < 0 || index.row() > m_animals.count())
+ return QVariant();
+
+ const Animal &animal = m_animals[index.row()];
+ if (role == TypeRole)
+ return animal.type();
+ else if (role == SizeRole)
+ return animal.size();
+ return QVariant();
+}
+
diff --git a/examples/declarative/modelviews/abstractitemmodel/model.h b/examples/declarative/modelviews/abstractitemmodel/model.h
new file mode 100644
index 0000000..1119837
--- /dev/null
+++ b/examples/declarative/modelviews/abstractitemmodel/model.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QAbstractListModel>
+#include <QStringList>
+
+//![0]
+class Animal
+{
+public:
+ Animal(const QString &type, const QString &size);
+//![0]
+
+ QString type() const;
+ QString size() const;
+
+private:
+ QString m_type;
+ QString m_size;
+//![1]
+};
+
+class AnimalModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+ enum AnimalRoles {
+ TypeRole = Qt::UserRole + 1,
+ SizeRole
+ };
+
+ AnimalModel(QObject *parent = 0);
+//![1]
+
+ void addAnimal(const Animal &animal);
+
+ int rowCount(const QModelIndex & parent = QModelIndex()) const;
+
+ QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
+
+private:
+ QList<Animal> m_animals;
+//![2]
+};
+//![2]
+
+
diff --git a/examples/declarative/modelviews/abstractitemmodel/view.qml b/examples/declarative/modelviews/abstractitemmodel/view.qml
new file mode 100644
index 0000000..591d89a
--- /dev/null
+++ b/examples/declarative/modelviews/abstractitemmodel/view.qml
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import Qt 4.7
+
+//![0]
+ListView {
+ width: 200; height: 250
+ anchors.fill: parent
+
+ model: myModel
+ delegate: Text { text: "Animal: " + type + ", " + size }
+}
+//![0]
+
diff --git a/examples/declarative/modelviews/objectlistmodel/dataobject.h b/examples/declarative/modelviews/objectlistmodel/dataobject.h
index c61e50c..17aa355 100644
--- a/examples/declarative/modelviews/objectlistmodel/dataobject.h
+++ b/examples/declarative/modelviews/objectlistmodel/dataobject.h
@@ -43,12 +43,14 @@
#include <QObject>
+//![0]
class DataObject : public QObject
{
Q_OBJECT
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged)
+//![0]
public:
DataObject(QObject *parent=0);
@@ -67,6 +69,8 @@ signals:
private:
QString m_name;
QString m_color;
+//![1]
};
+//![1]
#endif // DATAOBJECT_H
diff --git a/examples/declarative/modelviews/objectlistmodel/main.cpp b/examples/declarative/modelviews/objectlistmodel/main.cpp
index 25de8d1..89c22a1 100644
--- a/examples/declarative/modelviews/objectlistmodel/main.cpp
+++ b/examples/declarative/modelviews/objectlistmodel/main.cpp
@@ -53,20 +53,21 @@
model in QML
*/
+//![0]
int main(int argc, char ** argv)
{
QApplication app(argc, argv);
- QDeclarativeView view;
-
QList<QObject*> dataList;
dataList.append(new DataObject("Item 1", "red"));
dataList.append(new DataObject("Item 2", "green"));
dataList.append(new DataObject("Item 3", "blue"));
dataList.append(new DataObject("Item 4", "yellow"));
+ QDeclarativeView view;
QDeclarativeContext *ctxt = view.rootContext();
ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
+//![0]
view.setSource(QUrl("qrc:view.qml"));
view.show();
diff --git a/examples/declarative/modelviews/objectlistmodel/view.qml b/examples/declarative/modelviews/objectlistmodel/view.qml
index 034121c..c3cccdd 100644
--- a/examples/declarative/modelviews/objectlistmodel/view.qml
+++ b/examples/declarative/modelviews/objectlistmodel/view.qml
@@ -40,17 +40,17 @@
import Qt 4.7
+//![0]
ListView {
- width: 100
- height: 100
+ width: 100; height: 100
anchors.fill: parent
+
model: myModel
- delegate: Component {
- Rectangle {
- height: 25
- width: 100
- color: model.modelData.color
- Text { text: name }
- }
+ delegate: Rectangle {
+ height: 25
+ width: 100
+ color: model.modelData.color
+ Text { text: name }
}
}
+//![0]
diff --git a/examples/declarative/modelviews/stringlistmodel/main.cpp b/examples/declarative/modelviews/stringlistmodel/main.cpp
index b2ebd4b..bf46c63 100644
--- a/examples/declarative/modelviews/stringlistmodel/main.cpp
+++ b/examples/declarative/modelviews/stringlistmodel/main.cpp
@@ -56,16 +56,17 @@ int main(int argc, char ** argv)
{
QApplication app(argc, argv);
- QDeclarativeView view;
-
+//![0]
QStringList dataList;
dataList.append("Item 1");
dataList.append("Item 2");
dataList.append("Item 3");
dataList.append("Item 4");
+ QDeclarativeView view;
QDeclarativeContext *ctxt = view.rootContext();
ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
+//![0]
view.setSource(QUrl("qrc:view.qml"));
view.show();
diff --git a/examples/declarative/modelviews/stringlistmodel/view.qml b/examples/declarative/modelviews/stringlistmodel/view.qml
index ec5597d..3d789fd 100644
--- a/examples/declarative/modelviews/stringlistmodel/view.qml
+++ b/examples/declarative/modelviews/stringlistmodel/view.qml
@@ -39,17 +39,17 @@
****************************************************************************/
import Qt 4.7
+//![0]
ListView {
- width: 100
- height: 100
+ width: 100; height: 100
anchors.fill: parent
+
model: myModel
- delegate: Component {
- Rectangle {
- height: 25
- width: 100
- Text { text: modelData }
- }
+ delegate: Rectangle {
+ height: 25
+ width: 100
+ Text { text: modelData }
}
}
+//![0]
diff --git a/examples/declarative/ui-components/progressbar/content/ProgressBar.qml b/examples/declarative/ui-components/progressbar/content/ProgressBar.qml
index 829ab9b..6aa6765 100644
--- a/examples/declarative/ui-components/progressbar/content/ProgressBar.qml
+++ b/examples/declarative/ui-components/progressbar/content/ProgressBar.qml
@@ -66,7 +66,7 @@ Item {
width: highlight.widthDest
Behavior on width { SmoothedAnimation { velocity: 1200 } }
- anchors { left: parent.left; top: parent.top; bottom: parent.bottom; leftMargin: 3; topMargin: 3; bottomMargin: 3 }
+ anchors { left: parent.left; top: parent.top; bottom: parent.bottom; margins: 3 }
radius: 1
gradient: Gradient {
GradientStop { id: gradient1; position: 0.0 }
diff --git a/examples/declarative/ui-components/searchbox/SearchBox.qml b/examples/declarative/ui-components/searchbox/SearchBox.qml
index e6b9c8f..6d87837 100644
--- a/examples/declarative/ui-components/searchbox/SearchBox.qml
+++ b/examples/declarative/ui-components/searchbox/SearchBox.qml
@@ -73,7 +73,7 @@ FocusScope {
TextInput {
id: textInput
- anchors { left: parent.left; leftMargin: 8; verticalCenter: parent.verticalCenter }
+ anchors { left: parent.left; leftMargin: 8; right: clear.left; rightMargin: 8; verticalCenter: parent.verticalCenter }
focus: true
}
diff --git a/examples/declarative/ui-components/tabwidget/main.qml b/examples/declarative/ui-components/tabwidget/main.qml
index e11902a..4a27806 100644
--- a/examples/declarative/ui-components/tabwidget/main.qml
+++ b/examples/declarative/ui-components/tabwidget/main.qml
@@ -50,7 +50,7 @@ TabWidget {
color: "#e3e3e3"
Rectangle {
- anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 }
+ anchors.fill: parent; anchors.margins: 20
color: "#ff7f7f"
Text {
width: parent.width - 20
@@ -68,7 +68,7 @@ TabWidget {
color: "#e3e3e3"
Rectangle {
- anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 }
+ anchors.fill: parent; anchors.margins: 20
color: "#7fff7f"
Text {
width: parent.width - 20
@@ -85,7 +85,7 @@ TabWidget {
anchors.fill: parent; color: "#e3e3e3"
Rectangle {
- anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 }
+ anchors.fill: parent; anchors.margins: 20
color: "#7f7fff"
Text {
width: parent.width - 20