summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets/declarative
diff options
context:
space:
mode:
Diffstat (limited to 'doc/src/snippets/declarative')
-rw-r--r--doc/src/snippets/declarative/gradient.qml2
-rw-r--r--doc/src/snippets/declarative/texteditor.qml8
-rw-r--r--doc/src/snippets/declarative/xmlrole.qml81
-rw-r--r--doc/src/snippets/declarative/xmlrole.xml14
4 files changed, 102 insertions, 3 deletions
diff --git a/doc/src/snippets/declarative/gradient.qml b/doc/src/snippets/declarative/gradient.qml
index d25352b..7a68233 100644
--- a/doc/src/snippets/declarative/gradient.qml
+++ b/doc/src/snippets/declarative/gradient.qml
@@ -41,6 +41,7 @@
import Qt 4.7
+//![code]
Rectangle {
width: 100; height: 100
gradient: Gradient {
@@ -49,3 +50,4 @@ Rectangle {
GradientStop { position: 1.0; color: "green" }
}
}
+//![code]
diff --git a/doc/src/snippets/declarative/texteditor.qml b/doc/src/snippets/declarative/texteditor.qml
index 0bd79b5..6735c6c 100644
--- a/doc/src/snippets/declarative/texteditor.qml
+++ b/doc/src/snippets/declarative/texteditor.qml
@@ -45,7 +45,8 @@ Flickable {
id: flick
width: 300; height: 200;
- contentHeight: edit.height
+ contentWidth: edit.paintedWidth
+ contentHeight: edit.paintedHeight
clip: true
function ensureVisible(r)
@@ -62,9 +63,10 @@ Flickable {
TextEdit {
id: edit
- width: parent.width
+ width: flick.width
+ height: flick.height
focus: true
- wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
+ wrapMode: TextEdit.Wrap
onCursorRectangleChanged: flick.ensureVisible(cursorRectangle)
}
}
diff --git a/doc/src/snippets/declarative/xmlrole.qml b/doc/src/snippets/declarative/xmlrole.qml
new file mode 100644
index 0000000..6d04daf
--- /dev/null
+++ b/doc/src/snippets/declarative/xmlrole.qml
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** 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: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$
+**
+****************************************************************************/
+
+import Qt 4.7
+
+Rectangle {
+ width: 300; height: 200
+
+//![0]
+XmlListModel {
+ id: model
+//![0]
+ source: "xmlrole.xml"
+
+//![1]
+ // XmlRole queries will be made on <book> elements
+ query: "/catalogue/book"
+
+ // query the book title
+ XmlRole { name: "title"; query: "title/string()" }
+
+ // query the book's year
+ XmlRole { name: "year"; query: "year/number()" }
+
+ // query the book's type (the '@' indicates 'type' is an attribute, not an element)
+ XmlRole { name: "type"; query: "@type/string()" }
+
+ // query the book's first listed author (note in XPath the first index is 1, not 0)
+ XmlRole { name: "first_author"; query: "author[1]/string()" }
+}
+//![1]
+
+ListView {
+ width: 300; height: 200
+ model: model
+ delegate: Column {
+ Text { text: title + " (" + type + ")"; font.bold: true }
+ Text { text: first_author }
+ Text { text: year }
+ }
+}
+
+}
diff --git a/doc/src/snippets/declarative/xmlrole.xml b/doc/src/snippets/declarative/xmlrole.xml
new file mode 100644
index 0000000..c9f999e
--- /dev/null
+++ b/doc/src/snippets/declarative/xmlrole.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="iso-8859-1" ?>
+<catalogue>
+ <book type="Hardcover">
+ <title>C++ GUI Programming with Qt 4</title>
+ <year>2006</year>
+ <author>Jasmin Blanchette</author>
+ <author>Mark Summerfield</author>
+ </book>
+ <book type="Paperback">
+ <title>Programming with Qt</title>
+ <year>2002</year>
+ <author>Matthias Kalle Dalheimer</author>
+ </book>
+ </catalogue>