summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2010-08-25 16:00:47 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2010-08-25 16:00:47 (GMT)
commit913ea0d5cdee3a182a811db2bb9440aee679ae08 (patch)
tree79708faf5c379948eb5aa2f84cb24488a9cb0c4f /examples
parent5c45c66b1743645b77826ad61508a79eadd48414 (diff)
parentd9dd68c4400c3ca590ea425d6f3d070ea6094099 (diff)
downloadQt-913ea0d5cdee3a182a811db2bb9440aee679ae08.zip
Qt-913ea0d5cdee3a182a811db2bb9440aee679ae08.tar.gz
Qt-913ea0d5cdee3a182a811db2bb9440aee679ae08.tar.bz2
Merge remote branch 'origin/4.7' into qt-master-from-4.7
Conflicts: qmake/generators/win32/msbuild_objectmodel.cpp src/declarative/qml/qdeclarativexmlhttprequest.cpp src/opengl/opengl.pro src/opengl/qgl_p.h src/plugins/bearer/connman/qconnmanservice_linux.cpp tests/auto/qpainter/tst_qpainter.cpp tools/assistant/tools/assistant/helpviewer_qwv.h tools/assistant/tools/assistant/openpageswidget.h
Diffstat (limited to 'examples')
-rw-r--r--examples/declarative/cppextensions/referenceexamples/methods/birthdayparty.cpp80
-rw-r--r--examples/declarative/cppextensions/referenceexamples/methods/birthdayparty.h71
-rw-r--r--examples/declarative/cppextensions/referenceexamples/methods/example.qml58
-rw-r--r--examples/declarative/cppextensions/referenceexamples/methods/main.cpp68
-rw-r--r--examples/declarative/cppextensions/referenceexamples/methods/methods.pro18
-rw-r--r--examples/declarative/cppextensions/referenceexamples/methods/methods.qrc5
-rw-r--r--examples/declarative/cppextensions/referenceexamples/methods/person.cpp66
-rw-r--r--examples/declarative/cppextensions/referenceexamples/methods/person.h63
-rw-r--r--examples/declarative/cppextensions/referenceexamples/referenceexamples.pro3
-rw-r--r--examples/declarative/modelviews/package/view.qml3
-rw-r--r--examples/declarative/sqllocalstorage/hello.qml48
-rw-r--r--examples/declarative/threading/threadedlistmodel/timedisplay.qml40
-rw-r--r--examples/declarative/toys/clocks/content/Clock.qml6
-rw-r--r--examples/declarative/toys/tvtennis/tvtennis.qml4
-rw-r--r--examples/declarative/ui-components/dialcontrol/content/Dial.qml2
-rw-r--r--examples/declarative/ui-components/dialcontrol/dialcontrol.qml4
-rw-r--r--examples/declarative/ui-components/searchbox/SearchBox.qml1
-rw-r--r--examples/graphicsview/diagramscene/mainwindow.cpp29
18 files changed, 513 insertions, 56 deletions
diff --git a/examples/declarative/cppextensions/referenceexamples/methods/birthdayparty.cpp b/examples/declarative/cppextensions/referenceexamples/methods/birthdayparty.cpp
new file mode 100644
index 0000000..801c7ba
--- /dev/null
+++ b/examples/declarative/cppextensions/referenceexamples/methods/birthdayparty.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** 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 examples 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 "birthdayparty.h"
+
+BirthdayParty::BirthdayParty(QObject *parent)
+: QObject(parent), m_host(0)
+{
+}
+
+// ![0]
+Person *BirthdayParty::host() const
+{
+ return m_host;
+}
+
+void BirthdayParty::setHost(Person *c)
+{
+ m_host = c;
+}
+
+QDeclarativeListProperty<Person> BirthdayParty::guests()
+{
+ return QDeclarativeListProperty<Person>(this, m_guests);
+}
+
+int BirthdayParty::guestCount() const
+{
+ return m_guests.count();
+}
+
+Person *BirthdayParty::guest(int index) const
+{
+ return m_guests.at(index);
+}
+
+void BirthdayParty::invite(const QString &name)
+{
+ Person *person = new Person(this);
+ person->setName(name);
+ m_guests.append(person);
+}
+// ![0]
+
diff --git a/examples/declarative/cppextensions/referenceexamples/methods/birthdayparty.h b/examples/declarative/cppextensions/referenceexamples/methods/birthdayparty.h
new file mode 100644
index 0000000..b89a30e
--- /dev/null
+++ b/examples/declarative/cppextensions/referenceexamples/methods/birthdayparty.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** 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 examples 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$
+**
+****************************************************************************/
+#ifndef BIRTHDAYPARTY_H
+#define BIRTHDAYPARTY_H
+
+#include <QObject>
+#include <QDeclarativeListProperty>
+#include "person.h"
+
+class BirthdayParty : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(Person *host READ host WRITE setHost)
+ Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
+public:
+ BirthdayParty(QObject *parent = 0);
+
+ Person *host() const;
+ void setHost(Person *);
+
+ QDeclarativeListProperty<Person> guests();
+ int guestCount() const;
+ Person *guest(int) const;
+
+// ![0]
+ Q_INVOKABLE void invite(const QString &name);
+// ![0]
+
+private:
+ Person *m_host;
+ QList<Person *> m_guests;
+};
+
+#endif // BIRTHDAYPARTY_H
diff --git a/examples/declarative/cppextensions/referenceexamples/methods/example.qml b/examples/declarative/cppextensions/referenceexamples/methods/example.qml
new file mode 100644
index 0000000..c4698a2
--- /dev/null
+++ b/examples/declarative/cppextensions/referenceexamples/methods/example.qml
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** 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
+import People 1.0
+
+// ![0]
+BirthdayParty {
+ host: Person {
+ name: "Bob Jones"
+ shoeSize: 12
+ }
+ guests: [
+ Person { name: "Leo Hodges" },
+ Person { name: "Jack Smith" },
+ Person { name: "Anne Brown" }
+ ]
+
+ Component.onCompleted: invite("William Green")
+}
+// ![0]
diff --git a/examples/declarative/cppextensions/referenceexamples/methods/main.cpp b/examples/declarative/cppextensions/referenceexamples/methods/main.cpp
new file mode 100644
index 0000000..d974647
--- /dev/null
+++ b/examples/declarative/cppextensions/referenceexamples/methods/main.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** 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 examples 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 <QCoreApplication>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
+#include <QDebug>
+#include "birthdayparty.h"
+#include "person.h"
+
+int main(int argc, char ** argv)
+{
+ QCoreApplication app(argc, argv);
+
+ qmlRegisterType<BirthdayParty>("People", 1,0, "BirthdayParty");
+ qmlRegisterType<Person>("People", 1,0, "Person");
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, QUrl("qrc:example.qml"));
+ BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
+
+ if (party && party->host()) {
+ qWarning() << party->host()->name() << "is having a birthday!";
+ qWarning() << "They are inviting:";
+ for (int ii = 0; ii < party->guestCount(); ++ii)
+ qWarning() << " " << party->guest(ii)->name();
+ } else {
+ qWarning() << component.errors();
+ }
+
+ return 0;
+}
diff --git a/examples/declarative/cppextensions/referenceexamples/methods/methods.pro b/examples/declarative/cppextensions/referenceexamples/methods/methods.pro
new file mode 100644
index 0000000..a62927e
--- /dev/null
+++ b/examples/declarative/cppextensions/referenceexamples/methods/methods.pro
@@ -0,0 +1,18 @@
+TEMPLATE = app
+TARGET = methods
+DEPENDPATH += .
+INCLUDEPATH += .
+QT += declarative
+
+# Input
+SOURCES += main.cpp \
+ person.cpp \
+ birthdayparty.cpp
+HEADERS += person.h \
+ birthdayparty.h
+RESOURCES += methods.qrc
+
+target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/methods
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS methods.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/methods
+INSTALLS += target sources
diff --git a/examples/declarative/cppextensions/referenceexamples/methods/methods.qrc b/examples/declarative/cppextensions/referenceexamples/methods/methods.qrc
new file mode 100644
index 0000000..e2fa01d
--- /dev/null
+++ b/examples/declarative/cppextensions/referenceexamples/methods/methods.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>example.qml</file>
+</qresource>
+</RCC>
diff --git a/examples/declarative/cppextensions/referenceexamples/methods/person.cpp b/examples/declarative/cppextensions/referenceexamples/methods/person.cpp
new file mode 100644
index 0000000..beffe78
--- /dev/null
+++ b/examples/declarative/cppextensions/referenceexamples/methods/person.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 examples 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 "person.h"
+
+Person::Person(QObject *parent)
+: QObject(parent), m_shoeSize(0)
+{
+}
+
+QString Person::name() const
+{
+ return m_name;
+}
+
+void Person::setName(const QString &n)
+{
+ m_name = n;
+}
+
+int Person::shoeSize() const
+{
+ return m_shoeSize;
+}
+
+void Person::setShoeSize(int s)
+{
+ m_shoeSize = s;
+}
+
diff --git a/examples/declarative/cppextensions/referenceexamples/methods/person.h b/examples/declarative/cppextensions/referenceexamples/methods/person.h
new file mode 100644
index 0000000..8c950da
--- /dev/null
+++ b/examples/declarative/cppextensions/referenceexamples/methods/person.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** 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 examples 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$
+**
+****************************************************************************/
+#ifndef PERSON_H
+#define PERSON_H
+
+#include <QObject>
+
+class Person : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QString name READ name WRITE setName)
+ Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize)
+public:
+ Person(QObject *parent = 0);
+
+ QString name() const;
+ void setName(const QString &);
+
+ int shoeSize() const;
+ void setShoeSize(int);
+private:
+ QString m_name;
+ int m_shoeSize;
+};
+
+#endif // PERSON_H
diff --git a/examples/declarative/cppextensions/referenceexamples/referenceexamples.pro b/examples/declarative/cppextensions/referenceexamples/referenceexamples.pro
index 169c7ab..505cefd 100644
--- a/examples/declarative/cppextensions/referenceexamples/referenceexamples.pro
+++ b/examples/declarative/cppextensions/referenceexamples/referenceexamples.pro
@@ -10,4 +10,5 @@ SUBDIRS += \
grouped \
properties \
signal \
- valuesource
+ valuesource \
+ methods
diff --git a/examples/declarative/modelviews/package/view.qml b/examples/declarative/modelviews/package/view.qml
index 152881a..26230ef 100644
--- a/examples/declarative/modelviews/package/view.qml
+++ b/examples/declarative/modelviews/package/view.qml
@@ -40,7 +40,8 @@
import Qt 4.7
-Item {
+Rectangle {
+ color: "white"
width: 400
height: 200
diff --git a/examples/declarative/sqllocalstorage/hello.qml b/examples/declarative/sqllocalstorage/hello.qml
index 421a74c..19b7378 100644
--- a/examples/declarative/sqllocalstorage/hello.qml
+++ b/examples/declarative/sqllocalstorage/hello.qml
@@ -40,32 +40,38 @@
//![0]
import Qt 4.7
-Text {
- text: "?"
+Rectangle {
+ color: "white"
+ width: 200
+ height: 100
+
+ Text {
+ text: "?"
+ anchors.horizontalCenter: parent.horizontalCenter
+ function findGreetings() {
+ var db = openDatabaseSync("QDeclarativeExampleDB", "1.0", "The Example QML SQL!", 1000000);
- function findGreetings() {
- var db = openDatabaseSync("QDeclarativeExampleDB", "1.0", "The Example QML SQL!", 1000000);
+ db.transaction(
+ function(tx) {
+ // Create the database if it doesn't already exist
+ tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)');
- db.transaction(
- function(tx) {
- // Create the database if it doesn't already exist
- tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)');
+ // Add (another) greeting row
+ tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]);
- // Add (another) greeting row
- tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]);
+ // Show all added greetings
+ var rs = tx.executeSql('SELECT * FROM Greeting');
- // Show all added greetings
- var rs = tx.executeSql('SELECT * FROM Greeting');
-
- var r = ""
- for(var i = 0; i < rs.rows.length; i++) {
- r += rs.rows.item(i).salutation + ", " + rs.rows.item(i).salutee + "\n"
+ var r = ""
+ for(var i = 0; i < rs.rows.length; i++) {
+ r += rs.rows.item(i).salutation + ", " + rs.rows.item(i).salutee + "\n"
+ }
+ text = r
}
- text = r
- }
- )
- }
+ )
+ }
- Component.onCompleted: findGreetings()
+ Component.onCompleted: findGreetings()
+ }
}
//![0]
diff --git a/examples/declarative/threading/threadedlistmodel/timedisplay.qml b/examples/declarative/threading/threadedlistmodel/timedisplay.qml
index 997f7a0..d807955 100644
--- a/examples/declarative/threading/threadedlistmodel/timedisplay.qml
+++ b/examples/declarative/threading/threadedlistmodel/timedisplay.qml
@@ -41,31 +41,35 @@
// ![0]
import Qt 4.7
-ListView {
+Rectangle {
+ color: "white"
width: 200
height: 300
- model: listModel
- delegate: Component {
- Text { text: time }
- }
+ ListView {
+ anchors.fill: parent
+ model: listModel
+ delegate: Component {
+ Text { text: time }
+ }
- ListModel { id: listModel }
+ ListModel { id: listModel }
- WorkerScript {
- id: worker
- source: "dataloader.js"
- }
+ WorkerScript {
+ id: worker
+ source: "dataloader.js"
+ }
- Timer {
- id: timer
- interval: 2000; repeat: true
- running: true
- triggeredOnStart: true
+ Timer {
+ id: timer
+ interval: 2000; repeat: true
+ running: true
+ triggeredOnStart: true
- onTriggered: {
- var msg = {'action': 'appendCurrentTime', 'model': listModel};
- worker.sendMessage(msg);
+ onTriggered: {
+ var msg = {'action': 'appendCurrentTime', 'model': listModel};
+ worker.sendMessage(msg);
+ }
}
}
}
diff --git a/examples/declarative/toys/clocks/content/Clock.qml b/examples/declarative/toys/clocks/content/Clock.qml
index eaa14c6..765e8b8 100644
--- a/examples/declarative/toys/clocks/content/Clock.qml
+++ b/examples/declarative/toys/clocks/content/Clock.qml
@@ -77,7 +77,7 @@ Item {
origin.x: 7.5; origin.y: 73;
angle: (clock.hours * 30) + (clock.minutes * 0.5)
Behavior on angle {
- RotationAnimation{ direction: RotationAnimation.Clockwise }
+ SpringAnimation { spring: 2; damping: 0.2; modulus: 360 }
}
}
}
@@ -91,7 +91,7 @@ Item {
origin.x: 6.5; origin.y: 83;
angle: clock.minutes * 6
Behavior on angle {
- RotationAnimation{ direction: RotationAnimation.Clockwise }
+ SpringAnimation { spring: 2; damping: 0.2; modulus: 360 }
}
}
}
@@ -105,7 +105,7 @@ Item {
origin.x: 2.5; origin.y: 80;
angle: clock.seconds * 6
Behavior on angle {
- RotationAnimation{ direction: RotationAnimation.Clockwise }
+ SpringAnimation { spring: 2; damping: 0.2; modulus: 360 }
}
}
}
diff --git a/examples/declarative/toys/tvtennis/tvtennis.qml b/examples/declarative/toys/tvtennis/tvtennis.qml
index 2e144ed..4080c87 100644
--- a/examples/declarative/toys/tvtennis/tvtennis.qml
+++ b/examples/declarative/toys/tvtennis/tvtennis.qml
@@ -87,14 +87,14 @@ Rectangle {
color: "Lime"
x: 2; width: 20; height: 90
y: ball.direction == 'left' ? ball.y - 45 : page.height/2 -45;
- Behavior on y { SpringAnimation{ spring: 1; damping: .1; } }
+ Behavior on y { SpringAnimation{ velocity: 300 } }
}
Rectangle {
id: rightBat
color: "Lime"
x: page.width - 22; width: 20; height: 90
y: ball.direction == 'right' ? ball.y - 45 : page.height/2 -45;
- Behavior on y { SpringAnimation{ spring: 1; damping: .1; } }
+ Behavior on y { SpringAnimation{ velocity: 300 } }
}
// The rest, to make it look realistic, if neither ever scores...
diff --git a/examples/declarative/ui-components/dialcontrol/content/Dial.qml b/examples/declarative/ui-components/dialcontrol/content/Dial.qml
index b5074a64..3ffa09a 100644
--- a/examples/declarative/ui-components/dialcontrol/content/Dial.qml
+++ b/examples/declarative/ui-components/dialcontrol/content/Dial.qml
@@ -68,6 +68,7 @@ Item {
transform: Rotation {
id: needleRotation
origin.x: 5; origin.y: 65
+ //! [needle angle]
angle: Math.min(Math.max(-130, root.value*2.6 - 130), 133)
Behavior on angle {
SpringAnimation {
@@ -75,6 +76,7 @@ Item {
damping: .15
}
}
+ //! [needle angle]
}
}
//! [needle]
diff --git a/examples/declarative/ui-components/dialcontrol/dialcontrol.qml b/examples/declarative/ui-components/dialcontrol/dialcontrol.qml
index 95df68c..46cc3e6 100644
--- a/examples/declarative/ui-components/dialcontrol/dialcontrol.qml
+++ b/examples/declarative/ui-components/dialcontrol/dialcontrol.qml
@@ -38,8 +38,10 @@
**
****************************************************************************/
+//! [imports]
import Qt 4.7
import "content"
+//! [imports]
//! [0]
Rectangle {
@@ -87,4 +89,4 @@ Rectangle {
}
}
}
-//! [0] \ No newline at end of file
+//! [0]
diff --git a/examples/declarative/ui-components/searchbox/SearchBox.qml b/examples/declarative/ui-components/searchbox/SearchBox.qml
index 6d87837..8ef21b3 100644
--- a/examples/declarative/ui-components/searchbox/SearchBox.qml
+++ b/examples/declarative/ui-components/searchbox/SearchBox.qml
@@ -75,6 +75,7 @@ FocusScope {
id: textInput
anchors { left: parent.left; leftMargin: 8; right: clear.left; rightMargin: 8; verticalCenter: parent.verticalCenter }
focus: true
+ selectByMouse: true
}
Image {
diff --git a/examples/graphicsview/diagramscene/mainwindow.cpp b/examples/graphicsview/diagramscene/mainwindow.cpp
index e4fe633..03e821d 100644
--- a/examples/graphicsview/diagramscene/mainwindow.cpp
+++ b/examples/graphicsview/diagramscene/mainwindow.cpp
@@ -45,6 +45,7 @@
#include "diagramitem.h"
#include "diagramscene.h"
#include "diagramtextitem.h"
+#include "arrow.h"
const int InsertTextButton = 10;
@@ -55,7 +56,7 @@ MainWindow::MainWindow()
createToolBox();
createMenus();
- scene = new DiagramScene(itemMenu);
+ scene = new DiagramScene(itemMenu, this);
scene->setSceneRect(QRectF(0, 0, 5000, 5000));
connect(scene, SIGNAL(itemInserted(DiagramItem*)),
this, SLOT(itemInserted(DiagramItem*)));
@@ -123,11 +124,22 @@ void MainWindow::buttonGroupClicked(int id)
void MainWindow::deleteItem()
{
foreach (QGraphicsItem *item, scene->selectedItems()) {
- if (item->type() == DiagramItem::Type) {
- qgraphicsitem_cast<DiagramItem *>(item)->removeArrows();
+ if (item->type() == Arrow::Type) {
+ scene->removeItem(item);
+ Arrow *arrow = qgraphicsitem_cast<Arrow *>(item);
+ arrow->startItem()->removeArrow(arrow);
+ arrow->endItem()->removeArrow(arrow);
+ delete item;
}
- scene->removeItem(item);
}
+
+ foreach (QGraphicsItem *item, scene->selectedItems()) {
+ if (item->type() == DiagramItem::Type) {
+ qgraphicsitem_cast<DiagramItem *>(item)->removeArrows();
+ }
+ scene->removeItem(item);
+ delete item;
+ }
}
//! [3]
@@ -313,7 +325,7 @@ void MainWindow::about()
//! [21]
void MainWindow::createToolBox()
{
- buttonGroup = new QButtonGroup;
+ buttonGroup = new QButtonGroup(this);
buttonGroup->setExclusive(false);
connect(buttonGroup, SIGNAL(buttonClicked(int)),
this, SLOT(buttonGroupClicked(int)));
@@ -345,7 +357,7 @@ void MainWindow::createToolBox()
QWidget *itemWidget = new QWidget;
itemWidget->setLayout(layout);
- backgroundButtonGroup = new QButtonGroup;
+ backgroundButtonGroup = new QButtonGroup(this);
connect(backgroundButtonGroup, SIGNAL(buttonClicked(QAbstractButton*)),
this, SLOT(backgroundButtonGroupClicked(QAbstractButton*)));
@@ -460,7 +472,6 @@ void MainWindow::createToolbars()
editToolBar->addAction(sendBackAction);
fontCombo = new QFontComboBox();
- fontSizeCombo = new QComboBox();
connect(fontCombo, SIGNAL(currentFontChanged(QFont)),
this, SLOT(currentFontChanged(QFont)));
@@ -526,7 +537,7 @@ void MainWindow::createToolbars()
linePointerButton->setCheckable(true);
linePointerButton->setIcon(QIcon(":/images/linepointer.png"));
- pointerTypeGroup = new QButtonGroup;
+ pointerTypeGroup = new QButtonGroup(this);
pointerTypeGroup->addButton(pointerButton, int(DiagramScene::MoveItem));
pointerTypeGroup->addButton(linePointerButton,
int(DiagramScene::InsertLine));
@@ -605,7 +616,7 @@ QMenu *MainWindow::createColorMenu(const char *slot, QColor defaultColor)
names << tr("black") << tr("white") << tr("red") << tr("blue")
<< tr("yellow");
- QMenu *colorMenu = new QMenu;
+ QMenu *colorMenu = new QMenu(this);
for (int i = 0; i < colors.count(); ++i) {
QAction *action = new QAction(names.at(i), this);
action->setData(colors.at(i));