summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets
diff options
context:
space:
mode:
Diffstat (limited to 'doc/src/snippets')
-rw-r--r--doc/src/snippets/audio/main.cpp2
-rw-r--r--doc/src/snippets/code/doc_src_assistant-manual.qdoc8
-rw-r--r--doc/src/snippets/code/doc_src_emb-pointer.qdoc5
-rw-r--r--doc/src/snippets/code/doc_src_qmake-manual.qdoc2
-rw-r--r--doc/src/snippets/code/doc_src_wince-opengl.qdoc2
-rw-r--r--doc/src/snippets/code/src.qdbus.qdbuspendingcall.cpp1
-rw-r--r--doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp5
-rw-r--r--doc/src/snippets/code/src_corelib_statemachine_qstatemachine.cpp2
-rw-r--r--doc/src/snippets/code/src_gui_image_qicon.cpp4
-rw-r--r--doc/src/snippets/code/src_network_access_qnetworkaccessmanager.cpp18
-rw-r--r--doc/src/snippets/code/src_network_bearer_qnetworkconfigmanager.cpp49
-rw-r--r--doc/src/snippets/declarative/border-image.qml29
-rw-r--r--doc/src/snippets/declarative/codingconventions/dotproperties.qml28
-rw-r--r--doc/src/snippets/declarative/codingconventions/javascript-imports.qml7
-rw-r--r--doc/src/snippets/declarative/codingconventions/javascript.qml33
-rw-r--r--doc/src/snippets/declarative/codingconventions/lists.qml22
-rw-r--r--doc/src/snippets/declarative/codingconventions/myscript.js9
-rw-r--r--doc/src/snippets/declarative/codingconventions/photo.qml37
-rw-r--r--doc/src/snippets/declarative/comments.qml11
-rw-r--r--doc/src/snippets/declarative/drag.qml18
-rw-r--r--doc/src/snippets/declarative/flipable.qml37
-rw-r--r--doc/src/snippets/declarative/gradient.qml10
-rw-r--r--doc/src/snippets/declarative/gridview/dummydata/ContactModel.qml25
-rw-r--r--doc/src/snippets/declarative/gridview/gridview.qml47
-rw-r--r--doc/src/snippets/declarative/gridview/pics/portrait.pngbin0 -> 3126 bytes
-rw-r--r--doc/src/snippets/declarative/listview/dummydata/ContactModel.qml17
-rw-r--r--doc/src/snippets/declarative/listview/highlight.qml63
-rw-r--r--doc/src/snippets/declarative/listview/listview.qml49
-rw-r--r--doc/src/snippets/declarative/mouseregion.qml26
-rw-r--r--doc/src/snippets/declarative/pathview/dummydata/MenuModel.qml17
-rw-r--r--doc/src/snippets/declarative/pathview/pathattributes.qml36
-rw-r--r--doc/src/snippets/declarative/pathview/pathview.qml30
-rw-r--r--doc/src/snippets/declarative/pathview/pics/qtlogo-64.pngbin0 -> 2991 bytes
-rw-r--r--doc/src/snippets/declarative/pics/qt.pngbin0 -> 514 bytes
-rw-r--r--doc/src/snippets/declarative/repeater-index.qml15
-rw-r--r--doc/src/snippets/declarative/repeater.qml16
-rw-r--r--doc/src/snippets/declarative/rotation.qml33
-rw-r--r--doc/src/snippets/declarative/workerscript.qml24
-rw-r--r--doc/src/snippets/qelapsedtimer/main.cpp112
-rw-r--r--doc/src/snippets/qelapsedtimer/qelapsedtimer.pro2
40 files changed, 839 insertions, 12 deletions
diff --git a/doc/src/snippets/audio/main.cpp b/doc/src/snippets/audio/main.cpp
index 019f208..e21bf75 100644
--- a/doc/src/snippets/audio/main.cpp
+++ b/doc/src/snippets/audio/main.cpp
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the test suite of the Qt Toolkit.
+** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
diff --git a/doc/src/snippets/code/doc_src_assistant-manual.qdoc b/doc/src/snippets/code/doc_src_assistant-manual.qdoc
index 7438365..96aa71d 100644
--- a/doc/src/snippets/code/doc_src_assistant-manual.qdoc
+++ b/doc/src/snippets/code/doc_src_assistant-manual.qdoc
@@ -58,7 +58,7 @@ assistant -collectionFile file
<cacheDirectory>mycompany/myapplication</cacheDirectory>
<aboutMenuText>
<text>About My Application</text>
- <text language="de">Über meine Applikation...</text>
+ <text language="de">Ãœber meine Applikation...</text>
</aboutMenuText>
<aboutDialog>
<file>about.txt</file>
@@ -95,8 +95,7 @@ if (!process->waitForStarted())
//! [3]
QByteArray ba;
-ba.append("setSource qthelp://com.mycompany.1_0_0/doc/index.html");
-ba.append('\0');
+ba.append("setSource qthelp://com.mycompany.1_0_0/doc/index.html\n");
process->write(ba);
//! [3]
@@ -105,8 +104,7 @@ process->write(ba);
QByteArray ba;
ba.append("hide bookmarks;");
ba.append("hide index;");
-ba.append("setSource qthelp://com.mycompany.1_0_0/doc/index.html");
-ba.append('\0');
+ba.append("setSource qthelp://com.mycompany.1_0_0/doc/index.html\n");
process->write(ba);
//! [4]
diff --git a/doc/src/snippets/code/doc_src_emb-pointer.qdoc b/doc/src/snippets/code/doc_src_emb-pointer.qdoc
index 9661ae5..0d66e18 100644
--- a/doc/src/snippets/code/doc_src_emb-pointer.qdoc
+++ b/doc/src/snippets/code/doc_src_emb-pointer.qdoc
@@ -77,7 +77,10 @@ export QWS_MOUSE_PROTO="Vr41xx:press=500:/dev/misc/ts"
//! [7]
-./configure -L <path to tslib library> -I <path to tslib headers>
+....
+QMAKE_CFLAGS += -I<path to tslib headers>
+QMAKE_LFLAGS += -L<path to tslib library> -Wl,-rpath-link=<path to tslib library>
+....
//! [7]
diff --git a/doc/src/snippets/code/doc_src_qmake-manual.qdoc b/doc/src/snippets/code/doc_src_qmake-manual.qdoc
index d9e5d3c..5789662 100644
--- a/doc/src/snippets/code/doc_src_qmake-manual.qdoc
+++ b/doc/src/snippets/code/doc_src_qmake-manual.qdoc
@@ -886,7 +886,7 @@ TARGET.CAPABILITY += AllFiles
//! [133]
//! [134]
-TARGET.CAPABILITY = ALL -TCB
+TARGET.CAPABILITY = ALL -TCB -DRM -AllFiles
//! [134]
//! [135]
diff --git a/doc/src/snippets/code/doc_src_wince-opengl.qdoc b/doc/src/snippets/code/doc_src_wince-opengl.qdoc
index eef1540..601b00a 100644
--- a/doc/src/snippets/code/doc_src_wince-opengl.qdoc
+++ b/doc/src/snippets/code/doc_src_wince-opengl.qdoc
@@ -40,5 +40,5 @@
****************************************************************************/
//! [0]
-configure -platform win32-msvc2005 -xplatform wincewm50pocket-msvc2005 -opengl-es-cl
+configure -platform win32-msvc2005 -xplatform wincewm50pocket-msvc2005 -opengl-es-cm
//! [0]
diff --git a/doc/src/snippets/code/src.qdbus.qdbuspendingcall.cpp b/doc/src/snippets/code/src.qdbus.qdbuspendingcall.cpp
index 94a9f68..2867bd5a 100644
--- a/doc/src/snippets/code/src.qdbus.qdbuspendingcall.cpp
+++ b/doc/src/snippets/code/src.qdbus.qdbuspendingcall.cpp
@@ -61,5 +61,6 @@ void MyClass::callFinishedSlot(QDBusPendingCallWatcher *call)
QByteArray data = reply.argumentAt<1>();
showReply(text, data);
}
+ call->deleteLater();
}
//! [1]
diff --git a/doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp b/doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp
index bff72a0..19e37ba 100644
--- a/doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp
+++ b/doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp
@@ -108,3 +108,8 @@ int id = qRegisterMetaType<MyStruct>();
int id = qMetaTypeId<QString>(); // id is now QMetaType::QString
id = qMetaTypeId<MyStruct>(); // compile error if MyStruct not declared
//! [8]
+
+//! [9]
+typedef QString CustomString;
+qRegisterMetaType<CustomString>("CustomString");
+//! [9]
diff --git a/doc/src/snippets/code/src_corelib_statemachine_qstatemachine.cpp b/doc/src/snippets/code/src_corelib_statemachine_qstatemachine.cpp
index a18971d..1b1abea 100644
--- a/doc/src/snippets/code/src_corelib_statemachine_qstatemachine.cpp
+++ b/doc/src/snippets/code/src_corelib_statemachine_qstatemachine.cpp
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the test suite of the Qt Toolkit.
+** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
diff --git a/doc/src/snippets/code/src_gui_image_qicon.cpp b/doc/src/snippets/code/src_gui_image_qicon.cpp
index df1fa82..e0dcfa6 100644
--- a/doc/src/snippets/code/src_gui_image_qicon.cpp
+++ b/doc/src/snippets/code/src_gui_image_qicon.cpp
@@ -56,8 +56,8 @@ void MyWidget::drawIcon(QPainter *painter, QPoint pos)
QPixmap pixmap = icon.pixmap(QSize(22, 22),
isEnabled() ? QIcon::Normal
: QIcon::Disabled,
- isOn() ? QIcon::On
- : QIcon::Off);
+ isChecked() ? QIcon::On
+ : QIcon::Off);
painter->drawPixmap(pos, pixmap);
}
//! [2]
diff --git a/doc/src/snippets/code/src_network_access_qnetworkaccessmanager.cpp b/doc/src/snippets/code/src_network_access_qnetworkaccessmanager.cpp
index 643d0dd..1853650 100644
--- a/doc/src/snippets/code/src_network_access_qnetworkaccessmanager.cpp
+++ b/doc/src/snippets/code/src_network_access_qnetworkaccessmanager.cpp
@@ -60,3 +60,21 @@ connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
connect(reply, SIGNAL(sslErrors(QList<QSslError>)),
this, SLOT(slotSslErrors(QList<QSslError>)));
//! [1]
+
+//! [2]
+QNetworkConfigurationManager manager;
+networkAccessManager->setConfiguration(manager.defaultConfiguration());
+//! [2]
+
+//! [3]
+networkAccessManager->setConfiguration(QNetworkConfiguration());
+//! [3]
+
+//! [4]
+networkAccessManager->setNetworkAccessible(QNetworkAccessManager::NotAccessible);
+//! [4]
+
+//! [5]
+networkAccessManager->setNetworkAccessible(QNetworkAccessManager::Accessible);
+//! [5]
+
diff --git a/doc/src/snippets/code/src_network_bearer_qnetworkconfigmanager.cpp b/doc/src/snippets/code/src_network_bearer_qnetworkconfigmanager.cpp
new file mode 100644
index 0000000..e2cc4df
--- /dev/null
+++ b/doc/src/snippets/code/src_network_bearer_qnetworkconfigmanager.cpp
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** 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 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QNetworkConfigurationManager mgr;
+QList<QNetworkConfiguration> activeConfigs = mgr.allConfigurations(QNetworkConfiguration::Active)
+if (activeConfigs.count() > 0)
+ Q_ASSERT(mgr.isOnline())
+else
+ Q_ASSERT(!mgr.isOnline())
+//! [0]
diff --git a/doc/src/snippets/declarative/border-image.qml b/doc/src/snippets/declarative/border-image.qml
new file mode 100644
index 0000000..9c4247e
--- /dev/null
+++ b/doc/src/snippets/declarative/border-image.qml
@@ -0,0 +1,29 @@
+import Qt 4.7
+
+Rectangle {
+ id: page
+ color: "white"
+ width: 520; height: 280
+
+ Row {
+ anchors.centerIn: parent
+ spacing: 50
+//! [0]
+BorderImage {
+ width: 180; height: 180
+ border { left: 30; top: 30; right: 30; bottom: 30 }
+ horizontalTileMode: BorderImage.Stretch
+ verticalTileMode: BorderImage.Stretch
+ source: "content/colors.png"
+}
+
+BorderImage {
+ width: 180; height: 180
+ border { left: 30; top: 30; right: 30; bottom: 30 }
+ horizontalTileMode: BorderImage.Round
+ verticalTileMode: BorderImage.Round
+ source: "content/colors.png"
+}
+//! [0]
+ }
+}
diff --git a/doc/src/snippets/declarative/codingconventions/dotproperties.qml b/doc/src/snippets/declarative/codingconventions/dotproperties.qml
new file mode 100644
index 0000000..942b0b1
--- /dev/null
+++ b/doc/src/snippets/declarative/codingconventions/dotproperties.qml
@@ -0,0 +1,28 @@
+import Qt 4.7
+
+Item {
+
+//! [0]
+Rectangle {
+ anchors.left: parent.left; anchors.top: parent.top; anchors.right: parent.right; anchors.leftMargin: 20
+}
+
+Text {
+ text: "hello"
+ font.bold: true; font.italic: true; font.pixelSize: 20; font.capitalization: Font.AllUppercase
+}
+
+//! [0]
+
+//! [1]
+Rectangle {
+ anchors { left: parent.left; top: parent.top; right: parent.right; leftMargin: 20 }
+}
+
+Text {
+ text: "hello"
+ font { bold: true; italic: true; pixelSize: 20; capitalization: Font.AllUppercase }
+}
+//! [1]
+
+}
diff --git a/doc/src/snippets/declarative/codingconventions/javascript-imports.qml b/doc/src/snippets/declarative/codingconventions/javascript-imports.qml
new file mode 100644
index 0000000..417366c
--- /dev/null
+++ b/doc/src/snippets/declarative/codingconventions/javascript-imports.qml
@@ -0,0 +1,7 @@
+import Qt 4.7
+
+//![0]
+import "myscript.js" as Script
+
+Rectangle { color: "blue"; width: Script.calculateWidth(parent) }
+//![0]
diff --git a/doc/src/snippets/declarative/codingconventions/javascript.qml b/doc/src/snippets/declarative/codingconventions/javascript.qml
new file mode 100644
index 0000000..64b5a40
--- /dev/null
+++ b/doc/src/snippets/declarative/codingconventions/javascript.qml
@@ -0,0 +1,33 @@
+import Qt 4.7
+
+Rectangle {
+
+//![0]
+Rectangle { color: "blue"; width: parent.width / 3 }
+//![0]
+
+//![1]
+Rectangle {
+ color: "blue"
+ width: {
+ var w = parent.width / 3
+ console.debug(w)
+ return w
+ }
+}
+//![1]
+
+//![2]
+function calculateWidth(object)
+{
+ var w = object.width / 3
+ // ...
+ // more javascript code
+ // ...
+ console.debug(w)
+ return w
+}
+
+Rectangle { color: "blue"; width: calculateWidth(parent) }
+//![2]
+}
diff --git a/doc/src/snippets/declarative/codingconventions/lists.qml b/doc/src/snippets/declarative/codingconventions/lists.qml
new file mode 100644
index 0000000..63e8100
--- /dev/null
+++ b/doc/src/snippets/declarative/codingconventions/lists.qml
@@ -0,0 +1,22 @@
+import Qt 4.7
+
+Item {
+ Item {
+//! [0]
+states: [
+ State {
+ name: "open"
+ PropertyChanges { target: container; width: 200 }
+ }
+]
+//! [0]
+ }
+ Item {
+//! [1]
+states: State {
+ name: "open"
+ PropertyChanges { target: container; width: 200 }
+}
+//! [1]
+ }
+}
diff --git a/doc/src/snippets/declarative/codingconventions/myscript.js b/doc/src/snippets/declarative/codingconventions/myscript.js
new file mode 100644
index 0000000..cfa6462
--- /dev/null
+++ b/doc/src/snippets/declarative/codingconventions/myscript.js
@@ -0,0 +1,9 @@
+function calculateWidth(parent)
+{
+ var w = parent.width / 3
+ // ...
+ // more javascript code
+ // ...
+ console.debug(w)
+ return w
+}
diff --git a/doc/src/snippets/declarative/codingconventions/photo.qml b/doc/src/snippets/declarative/codingconventions/photo.qml
new file mode 100644
index 0000000..c28c2c9
--- /dev/null
+++ b/doc/src/snippets/declarative/codingconventions/photo.qml
@@ -0,0 +1,37 @@
+import Qt 4.7
+
+//! [0]
+Rectangle {
+ id: photo // id on the first line makes it easy to find an object
+
+ property bool thumbnail: false // property declarations
+ property alias image: photoImage.source
+
+ signal clicked // signal declarations
+
+ function doSomething(x) { // javascript functions
+ return x + photoImage.width
+ }
+
+ x: 20; y: 20; width: 200; height: 150 // object properties
+ color: "gray" // try to group related properties together
+
+ Rectangle { // child objects
+ id: border
+ anchors.centerIn: parent; color: "white"
+
+ Image { id: photoImage; anchors.centerIn: parent }
+ }
+
+ states: State { // states
+ name: "selected"
+ PropertyChanges { target: border; color: "red" }
+ }
+
+ transitions: Transition { // transitions
+ from: ""; to: "selected"
+ ColorAnimation { target: border; duration: 200 }
+ }
+}
+//! [0]
+
diff --git a/doc/src/snippets/declarative/comments.qml b/doc/src/snippets/declarative/comments.qml
new file mode 100644
index 0000000..ab1bbc9
--- /dev/null
+++ b/doc/src/snippets/declarative/comments.qml
@@ -0,0 +1,11 @@
+import Qt 4.7
+
+Text {
+ text: "Hello world!" //a basic greeting
+ /*
+ We want this text to stand out from the rest so
+ we give it a large size and different font.
+ */
+ font.family: "Helvetica"
+ font.pointSize: 24
+}
diff --git a/doc/src/snippets/declarative/drag.qml b/doc/src/snippets/declarative/drag.qml
new file mode 100644
index 0000000..9465efb
--- /dev/null
+++ b/doc/src/snippets/declarative/drag.qml
@@ -0,0 +1,18 @@
+import Qt 4.7
+
+//! [0]
+Rectangle {
+ id: blurtest; width: 600; height: 200; color: "white"
+ Image {
+ id: pic; source: "qtlogo-64.png"; anchors.verticalCenter: parent.verticalCenter
+ opacity: (600.0-pic.x) / 600;
+ MouseArea {
+ anchors.fill: parent
+ drag.target: pic
+ drag.axis: "XAxis"
+ drag.minimumX: 0
+ drag.maximumX: blurtest.width-pic.width
+ }
+ }
+}
+//! [0]
diff --git a/doc/src/snippets/declarative/flipable.qml b/doc/src/snippets/declarative/flipable.qml
new file mode 100644
index 0000000..ae74345
--- /dev/null
+++ b/doc/src/snippets/declarative/flipable.qml
@@ -0,0 +1,37 @@
+//! [0]
+import Qt 4.7
+
+Flipable {
+ id: flipable
+ width: 240
+ height: 240
+
+ property int angle: 0
+ property bool flipped: false
+
+ front: Image { source: "front.png" }
+ back: Image { source: "back.png" }
+
+ transform: Rotation {
+ origin.x: flipable.width/2; origin.y: flipable.height/2
+ axis.x: 0; axis.y: 1; axis.z: 0 // rotate around y-axis
+ angle: flipable.angle
+ }
+
+ states: State {
+ name: "back"
+ PropertyChanges { target: flipable; angle: 180 }
+ when: flipable.flipped
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "angle"; duration: 1000 }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: flipable.flipped = !flipable.flipped
+ }
+}
+//! [0]
+
diff --git a/doc/src/snippets/declarative/gradient.qml b/doc/src/snippets/declarative/gradient.qml
new file mode 100644
index 0000000..168398d
--- /dev/null
+++ b/doc/src/snippets/declarative/gradient.qml
@@ -0,0 +1,10 @@
+import Qt 4.7
+
+Rectangle {
+ width: 100; height: 100
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "red" }
+ GradientStop { position: 0.33; color: "yellow" }
+ GradientStop { position: 1.0; color: "green" }
+ }
+}
diff --git a/doc/src/snippets/declarative/gridview/dummydata/ContactModel.qml b/doc/src/snippets/declarative/gridview/dummydata/ContactModel.qml
new file mode 100644
index 0000000..90f139d
--- /dev/null
+++ b/doc/src/snippets/declarative/gridview/dummydata/ContactModel.qml
@@ -0,0 +1,25 @@
+import Qt 4.7
+
+ListModel {
+ id: contactModel
+ ListElement {
+ name: "Bill Smith"
+ number: "555 3264"
+ portrait: "pics/portrait.png"
+ }
+ ListElement {
+ name: "Jim Williams"
+ number: "555 5673"
+ portrait: "pics/portrait.png"
+ }
+ ListElement {
+ name: "John Brown"
+ number: "555 8426"
+ portrait: "pics/portrait.png"
+ }
+ ListElement {
+ name: "Sam Wise"
+ number: "555 0473"
+ portrait: "pics/portrait.png"
+ }
+}
diff --git a/doc/src/snippets/declarative/gridview/gridview.qml b/doc/src/snippets/declarative/gridview/gridview.qml
new file mode 100644
index 0000000..1d3df97
--- /dev/null
+++ b/doc/src/snippets/declarative/gridview/gridview.qml
@@ -0,0 +1,47 @@
+import Qt 4.7
+
+//! [3]
+Rectangle {
+ width: 240; height: 180; color: "white"
+ // ContactModel model is defined in dummydata/ContactModel.qml
+ // The viewer automatically loads files in dummydata/* to assist
+ // development without a real data source.
+
+ // Define a delegate component. A component will be
+ // instantiated for each visible item in the list.
+//! [0]
+ Component {
+ id: delegate
+ Item {
+ id: wrapper
+ width: 80; height: 78
+ Column {
+ Image { source: portrait; anchors.horizontalCenter: parent.horizontalCenter }
+ Text { text: name; anchors.horizontalCenter: parent.horizontalCenter }
+ }
+ }
+ }
+//! [0]
+ // Define a highlight component. Just one of these will be instantiated
+ // by each ListView and placed behind the current item.
+//! [1]
+ Component {
+ id: highlight
+ Rectangle {
+ color: "lightsteelblue"
+ radius: 5
+ }
+ }
+//! [1]
+ // The actual grid
+//! [2]
+ GridView {
+ width: parent.width; height: parent.height
+ model: ContactModel; delegate: delegate
+ cellWidth: 80; cellHeight: 80
+ highlight: highlight
+ focus: true
+ }
+//! [2]
+}
+//! [3]
diff --git a/doc/src/snippets/declarative/gridview/pics/portrait.png b/doc/src/snippets/declarative/gridview/pics/portrait.png
new file mode 100644
index 0000000..fb5052a
--- /dev/null
+++ b/doc/src/snippets/declarative/gridview/pics/portrait.png
Binary files differ
diff --git a/doc/src/snippets/declarative/listview/dummydata/ContactModel.qml b/doc/src/snippets/declarative/listview/dummydata/ContactModel.qml
new file mode 100644
index 0000000..20687cf
--- /dev/null
+++ b/doc/src/snippets/declarative/listview/dummydata/ContactModel.qml
@@ -0,0 +1,17 @@
+import Qt 4.7
+
+ListModel {
+ id: contactModel
+ ListElement {
+ name: "Bill Smith"
+ number: "555 3264"
+ }
+ ListElement {
+ name: "John Brown"
+ number: "555 8426"
+ }
+ ListElement {
+ name: "Sam Wise"
+ number: "555 0473"
+ }
+}
diff --git a/doc/src/snippets/declarative/listview/highlight.qml b/doc/src/snippets/declarative/listview/highlight.qml
new file mode 100644
index 0000000..794b3f2
--- /dev/null
+++ b/doc/src/snippets/declarative/listview/highlight.qml
@@ -0,0 +1,63 @@
+import Qt 4.7
+
+Rectangle {
+ width: 180; height: 200; color: "white"
+
+ // ContactModel model is defined in dummydata/ContactModel.qml
+ // The viewer automatically loads files in dummydata/* to assist
+ // development without a real data source.
+
+ // Define a delegate component. A component will be
+ // instantiated for each visible item in the list.
+//! [0]
+ Component {
+ id: delegate
+ Item {
+ id: wrapper
+ width: 180; height: 40
+ Column {
+ x: 5; y: 5
+ Text { text: '<b>Name:</b> ' + name }
+ Text { text: '<b>Number:</b> ' + number }
+ }
+ // Use the ListView.isCurrentItem attached property to
+ // indent the item if it is the current item.
+ states: [
+ State {
+ name: "Current"
+ when: wrapper.ListView.isCurrentItem
+ PropertyChanges { target: wrapper; x: 10 }
+ }
+ ]
+ transitions: [
+ Transition { NumberAnimation { properties: "x"; duration: 200 } }
+ ]
+ }
+ }
+//! [0]
+ // Specify a highlight with custom movement. Note that autoHighlight
+ // is set to false in the ListView so that we can control how the
+ // highlight moves to the current item.
+//! [1]
+ Component {
+ id: highlight
+ Rectangle {
+ width: 180; height: 40
+ color: "lightsteelblue"; radius: 5
+ SpringFollow on y {
+ to: list.currentItem.y
+ spring: 3
+ damping: 0.2
+ }
+ }
+ }
+ ListView {
+ id: list
+ width: parent.height; height: parent.height
+ model: ContactModel; delegate: delegate
+ highlight: highlight
+ highlightFollowsCurrentItem: false
+ focus: true
+ }
+//! [1]
+}
diff --git a/doc/src/snippets/declarative/listview/listview.qml b/doc/src/snippets/declarative/listview/listview.qml
new file mode 100644
index 0000000..61bf126
--- /dev/null
+++ b/doc/src/snippets/declarative/listview/listview.qml
@@ -0,0 +1,49 @@
+import Qt 4.7
+
+//! [3]
+Rectangle {
+ width: 180; height: 200; color: "white"
+
+ // ContactModel model is defined in dummydata/ContactModel.qml
+ // The viewer automatically loads files in dummydata/* to assist
+ // development without a real data source.
+
+ // Define a delegate component. A component will be
+ // instantiated for each visible item in the list.
+//! [0]
+ Component {
+ id: delegate
+ Item {
+ id: wrapper
+ width: 180; height: 40
+ Column {
+ x: 5; y: 5
+ Text { text: '<b>Name:</b> ' + name }
+ Text { text: '<b>Number:</b> ' + number }
+ }
+ }
+ }
+//! [0]
+ // Define a highlight component. Just one of these will be instantiated
+ // by each ListView and placed behind the current item.
+//! [1]
+ Component {
+ id: highlight
+ Rectangle {
+ color: "lightsteelblue"
+ radius: 5
+ }
+ }
+//! [1]
+ // The actual list
+//! [2]
+ ListView {
+ width: parent.width; height: parent.height
+ model: ContactModel
+ delegate: delegate
+ highlight: highlight
+ focus: true
+ }
+//! [2]
+}
+//! [3]
diff --git a/doc/src/snippets/declarative/mouseregion.qml b/doc/src/snippets/declarative/mouseregion.qml
new file mode 100644
index 0000000..a464069
--- /dev/null
+++ b/doc/src/snippets/declarative/mouseregion.qml
@@ -0,0 +1,26 @@
+import Qt 4.7
+
+Rectangle { width: 200; height: 100
+Row {
+//! [0]
+Rectangle { width: 100; height: 100; color: "green"
+ MouseArea { anchors.fill: parent; onClicked: { parent.color = 'red' } }
+}
+//! [0]
+//! [1]
+Rectangle {
+ width: 100; height: 100; color: "green"
+ MouseArea {
+ anchors.fill: parent
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
+ onClicked: {
+ if (mouse.button == Qt.RightButton)
+ parent.color = 'blue';
+ else
+ parent.color = 'red';
+ }
+ }
+}
+//! [1]
+}
+}
diff --git a/doc/src/snippets/declarative/pathview/dummydata/MenuModel.qml b/doc/src/snippets/declarative/pathview/dummydata/MenuModel.qml
new file mode 100644
index 0000000..4004076
--- /dev/null
+++ b/doc/src/snippets/declarative/pathview/dummydata/MenuModel.qml
@@ -0,0 +1,17 @@
+import Qt 4.7
+
+ListModel {
+ id: menuModel
+ ListElement {
+ name: "Bill Jones"
+ icon: "pics/qtlogo-64.png"
+ }
+ ListElement {
+ name: "Jane Doe"
+ icon: "pics/qtlogo-64.png"
+ }
+ ListElement {
+ name: "John Smith"
+ icon: "pics/qtlogo-64.png"
+ }
+}
diff --git a/doc/src/snippets/declarative/pathview/pathattributes.qml b/doc/src/snippets/declarative/pathview/pathattributes.qml
new file mode 100644
index 0000000..ba860c2
--- /dev/null
+++ b/doc/src/snippets/declarative/pathview/pathattributes.qml
@@ -0,0 +1,36 @@
+import Qt 4.7
+
+Rectangle {
+ width: 240; height: 200; color: 'white'
+//! [0]
+//! [1]
+ Component {
+ id: delegate
+ Item {
+ id: wrapper
+ width: 80; height: 80
+ scale: PathView.scale
+ opacity: PathView.opacity
+ Column {
+ Image { anchors.horizontalCenter: name.horizontalCenter; width: 64; height: 64; source: icon }
+ Text { text: name; font.pointSize: 16}
+ }
+ }
+ }
+//! [1]
+//! [2]
+ PathView {
+ anchors.fill: parent; model: MenuModel; delegate: delegate
+ path: Path {
+ startX: 120; startY: 100
+ PathAttribute { name: "scale"; value: 1.0 }
+ PathAttribute { name: "opacity"; value: 1.0 }
+ PathQuad { x: 120; y: 25; controlX: 260; controlY: 75 }
+ PathAttribute { name: "scale"; value: 0.3 }
+ PathAttribute { name: "opacity"; value: 0.5 }
+ PathQuad { x: 120; y: 100; controlX: -20; controlY: 75 }
+ }
+ }
+//! [2]
+//! [0]
+}
diff --git a/doc/src/snippets/declarative/pathview/pathview.qml b/doc/src/snippets/declarative/pathview/pathview.qml
new file mode 100644
index 0000000..3686398
--- /dev/null
+++ b/doc/src/snippets/declarative/pathview/pathview.qml
@@ -0,0 +1,30 @@
+import Qt 4.7
+
+Rectangle {
+ width: 240; height: 200; color: 'white'
+//! [0]
+//! [1]
+ Component {
+ id: delegate
+ Item {
+ id: wrapper
+ width: 80; height: 80
+ Column {
+ Image { anchors.horizontalCenter: name.horizontalCenter; width: 64; height: 64; source: icon }
+ Text { text: name; font.pointSize: 16}
+ }
+ }
+ }
+//! [1]
+//! [2]
+ PathView {
+ anchors.fill: parent; model: MenuModel; delegate: delegate
+ path: Path {
+ startX: 120; startY: 100
+ PathQuad { x: 120; y: 25; controlX: 260; controlY: 75 }
+ PathQuad { x: 120; y: 100; controlX: -20; controlY: 75 }
+ }
+ }
+//! [2]
+//! [0]
+}
diff --git a/doc/src/snippets/declarative/pathview/pics/qtlogo-64.png b/doc/src/snippets/declarative/pathview/pics/qtlogo-64.png
new file mode 100644
index 0000000..4f68e16
--- /dev/null
+++ b/doc/src/snippets/declarative/pathview/pics/qtlogo-64.png
Binary files differ
diff --git a/doc/src/snippets/declarative/pics/qt.png b/doc/src/snippets/declarative/pics/qt.png
new file mode 100644
index 0000000..cbed1a9
--- /dev/null
+++ b/doc/src/snippets/declarative/pics/qt.png
Binary files differ
diff --git a/doc/src/snippets/declarative/repeater-index.qml b/doc/src/snippets/declarative/repeater-index.qml
new file mode 100644
index 0000000..709eaf2
--- /dev/null
+++ b/doc/src/snippets/declarative/repeater-index.qml
@@ -0,0 +1,15 @@
+import Qt 4.7
+
+Rectangle {
+ width: 50; height: childrenRect.height; color: "white"
+
+//! [0]
+ Column {
+ Repeater {
+ model: 10
+ Text { text: "I'm item " + index }
+ }
+ }
+//! [0]
+}
+
diff --git a/doc/src/snippets/declarative/repeater.qml b/doc/src/snippets/declarative/repeater.qml
new file mode 100644
index 0000000..02a8208
--- /dev/null
+++ b/doc/src/snippets/declarative/repeater.qml
@@ -0,0 +1,16 @@
+import Qt 4.7
+
+Rectangle {
+ width: 220; height: 20; color: "white"
+
+//! [0]
+ Row {
+ Rectangle { width: 10; height: 20; color: "red" }
+ Repeater {
+ model: 10
+ Rectangle { width: 20; height: 20; radius: 10; color: "green" }
+ }
+ Rectangle { width: 10; height: 20; color: "blue" }
+ }
+//! [0]
+}
diff --git a/doc/src/snippets/declarative/rotation.qml b/doc/src/snippets/declarative/rotation.qml
new file mode 100644
index 0000000..f2fd78c
--- /dev/null
+++ b/doc/src/snippets/declarative/rotation.qml
@@ -0,0 +1,33 @@
+import Qt 4.7
+
+Rectangle {
+ width: 360; height: 80
+ color: "white"
+//! [0]
+ Row {
+ x: 10; y: 10
+ spacing: 10
+ Image { source: "pics/qt.png" }
+ Image {
+ source: "pics/qt.png"
+ transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 18 }
+ smooth: true
+ }
+ Image {
+ source: "pics/qt.png"
+ transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 36 }
+ smooth: true
+ }
+ Image {
+ source: "pics/qt.png"
+ transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 54 }
+ smooth: true
+ }
+ Image {
+ source: "pics/qt.png"
+ transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 72 }
+ smooth: true
+ }
+ }
+//! [0]
+}
diff --git a/doc/src/snippets/declarative/workerscript.qml b/doc/src/snippets/declarative/workerscript.qml
new file mode 100644
index 0000000..838e7e5
--- /dev/null
+++ b/doc/src/snippets/declarative/workerscript.qml
@@ -0,0 +1,24 @@
+//![0]
+import Qt 4.7
+
+Rectangle {
+ width: 300; height: 300
+
+ Text {
+ id: myText
+ text: 'Click anywhere'
+ }
+
+ WorkerScript {
+ id: myWorker
+ source: "script.js"
+
+ onMessage: myText.text = messageObject.reply
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: myWorker.sendMessage({ 'x': mouse.x, 'y': mouse.y })
+ }
+}
+//![0]
diff --git a/doc/src/snippets/qelapsedtimer/main.cpp b/doc/src/snippets/qelapsedtimer/main.cpp
new file mode 100644
index 0000000..9d0421f
--- /dev/null
+++ b/doc/src/snippets/qelapsedtimer/main.cpp
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** 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 QtNetwork module 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtCore>
+
+void slowOperation1()
+{
+ static char buf[256];
+ for (int i = 0; i < (1<<20); ++i)
+ buf[i % sizeof buf] = i;
+}
+
+void slowOperation2(int) { slowOperation1(); }
+
+void startExample()
+{
+//![0]
+ QElapsedTimer timer;
+ timer.start();
+
+ slowOperation1();
+
+ qDebug() << "The slow operation took" << timer.elapsed() << "milliseconds";
+//![0]
+}
+
+//![1]
+void executeSlowOperations(int timeout)
+{
+ QElapsedTimer timer;
+ timer.start();
+ slowOperation1();
+
+ int remainingTime = timeout - timer.elapsed();
+ if (remainingTime > 0)
+ slowOperation2(remainingTime);
+}
+//![1]
+
+//![2]
+void executeOperationsForTime(int ms)
+{
+ QElapsedTimer timer;
+ timer.start();
+
+ while (!timer.hasExpired(ms))
+ slowOperation1();
+}
+//![2]
+
+int restartExample()
+{
+//![3]
+ QElapsedTimer timer;
+
+ int count = 1;
+ timer.start();
+ do {
+ count *= 2;
+ slowOperation2(count);
+ } while (timer.restart() < 250);
+
+ return count;
+//![3]
+}
+
+int main(int argc, char **argv)
+{
+ QCoreApplication app(argc, argv);
+
+ startExample();
+ restartExample();
+ executeSlowOperations(5);
+ executeOperationsForTime(5);
+}
diff --git a/doc/src/snippets/qelapsedtimer/qelapsedtimer.pro b/doc/src/snippets/qelapsedtimer/qelapsedtimer.pro
new file mode 100644
index 0000000..b0a8f66
--- /dev/null
+++ b/doc/src/snippets/qelapsedtimer/qelapsedtimer.pro
@@ -0,0 +1,2 @@
+SOURCES = main.cpp
+QT -= gui