diff options
Diffstat (limited to 'doc/src')
36 files changed, 294 insertions, 35 deletions
diff --git a/doc/src/declarative/advtutorial.qdoc b/doc/src/declarative/advtutorial.qdoc index 47504ae..abfeadb 100644 --- a/doc/src/declarative/advtutorial.qdoc +++ b/doc/src/declarative/advtutorial.qdoc @@ -178,7 +178,7 @@ The \c createBlock() function creates a block from the \c Block.qml file and moves the new block to its position on the game canvas. This involves several steps: \list -\o \l {Qt.createComponent(url file)}{Qt.createComponent()} is called to generate an element from \c Block.qml. +\o \l {Qt::createComponent()}{Qt.createComponent()} is called to generate an element from \c Block.qml. If the component is ready, we can call \c createObject() to create an instance of the \c Block item. \o If \c createObject() returned null (i.e. if there was an error while loading the object), print the error information. @@ -468,6 +468,6 @@ By following this tutorial you've seen how you can write a fully functional appl \endlist There is so much more to learn about QML that we haven't been able to cover in this tutorial. Check out all the -demos and examples and the \l {Declarative UI Using QML}{documentation} to find out all the things you can do with QML! +demos and examples and the \l {Qt Quick}{documentation} to find out all the things you can do with QML! */ diff --git a/doc/src/declarative/dynamicobjects.qdoc b/doc/src/declarative/dynamicobjects.qdoc index 633489b..5e606f4 100644 --- a/doc/src/declarative/dynamicobjects.qdoc +++ b/doc/src/declarative/dynamicobjects.qdoc @@ -56,15 +56,15 @@ application, and there are no C++ components involved. \section1 Creating Objects Dynamically There are two ways to create objects dynamically from JavaScript. You can either call -\l {Qt.createComponent(url file)}{Qt.createComponent()} to create -a component which instantiates items, or use \l{Qt.createQmlObject(string qml, object parent, string filepath)}{Qt.createQmlObject()} +\l {Qt::createComponent()}{Qt.createComponent()} to create +a component which instantiates items, or use \l{Qt::createQmlObject()}{Qt.createQmlObject()} to create an item from a string of QML. Creating a component is better if you have a predefined item, and you want to create dynamic instances of that item; creating an item from a string of QML is useful when the item QML itself is generated at runtime. If you have a component specified in a QML file, you can dynamically load it with -the \l {Qt.createComponent(url file)}{Qt.createComponent()} function on the \l{QML Global Object}. +the \l {Qt::createComponent()}{Qt.createComponent()} function on the \l{QML Global Object}. This function takes the URL of the QML file as its only argument and returns a component object which can be used to create and load that QML file. @@ -98,10 +98,10 @@ in \c main.qml). After creating an item, you must set its parent to an item with Otherwise your dynamically created item will not appear in the scene. When using files with relative paths, the path should -be relative to the file where \l {Qt.createComponent(url file)}{Qt.createComponent()} is executed. +be relative to the file where \l {Qt::createComponent()}{Qt.createComponent()} is executed. If the QML component does not exist until runtime, you can create a QML item from -a string of QML using the \l{Qt.createQmlObject(string qml, object parent, string filepath)}{Qt.createQmlObject()} function, as in the following example: +a string of QML using the \l{Qt::createQmlObject()}{Qt.createQmlObject()} function, as in the following example: \snippet doc/src/snippets/declarative/createQmlObject.qml 0 @@ -121,9 +121,9 @@ the bindings in the dynamic item will no longer work. The actual creation context depends on how an item is created: \list -\o If \l {Qt.createComponent(url file)}{Qt.createComponent()} is used, the creation context +\o If \l {Qt::createComponent()}{Qt.createComponent()} is used, the creation context is the QDeclarativeContext in which this method is called -\o If \l{Qt.createQmlObject(string qml, object parent, string filepath)}{Qt.createQmlObject()} +\o If \l{Qt::createQmlObject()}{Qt.createQmlObject()} if called, it is the context of the item used as the second argument to this method \o If a \c {Component{}} item is defined and \l {Component::createObject()}{createObject()} is called on that item, it is the context in which the \c Component is defined diff --git a/doc/src/declarative/examples.qdoc b/doc/src/declarative/examples.qdoc index 6e0426c..5cb83fa 100644 --- a/doc/src/declarative/examples.qdoc +++ b/doc/src/declarative/examples.qdoc @@ -84,7 +84,10 @@ For example, from your build directory, run: \o \l{declarative/imageelements/borderimage}{BorderImage} \endlist -\section2 \l{declarative/positioners}{Positioners} +\section2 Positioners +\list +\o \l{declarative/positioners}{Example} +\endlist \section2 Key Interaction \list @@ -99,6 +102,7 @@ For example, from your build directory, run: \section2 UI Components \list +\o \l{declarative/ui-components/dialcontrol}{Dial control} \o \l{declarative/ui-components/flipable}{Flipable} \o \l{declarative/ui-components/progressbar}{Progress bar} \o \l{declarative/ui-components/scrollbar}{Scroll bar} @@ -112,10 +116,10 @@ For example, from your build directory, run: \list \o \l{declarative/modelviews/gridview}{GridView} \o \l{declarative/modelviews/listview}{ListView} -\o \l{declarative/modelviews/objectlistmodel}{Object list model} +\o \l{declarative/modelviews/objectlistmodel}{Object ListModel} \o \l{declarative/modelviews/package}{Package} \o \l{declarative/modelviews/parallax}{Parallax} -\o \l{declarative/modelviews/stringlistmodel}{String list model} +\o \l{declarative/modelviews/stringlistmodel}{String ListModel} \o \l{declarative/modelviews/webview}{WebView} \endlist @@ -124,7 +128,10 @@ For example, from your build directory, run: \o \l{declarative/xml/xmlhttprequest}{XmlHttpRequest} \endlist -\section2 \l{declarative/i18n}{Internationalization (i18n)} +\section2 Internationalization (i18n) +\list +\o \l{declarative/i18n}{Example} +\endlist \section2 Threading \list @@ -132,11 +139,14 @@ For example, from your build directory, run: \o \l{declarative/threading/workerscript}{WorkerScript} \endlist -\section2 \l{declarative/sqllocalstorage}{SQL Local Storage} +\section2 SQL Local Storage +\list +\o \l{declarative/sqllocalstorage}{Example} +\endlist \section2 C++ Extensions \list -\o \l{declarative-cppextensions-reference.html}{Reference examples} (discussed in \l {Extending QML in C++}) +\o \l{declarative-cppextensions-reference.html}{Reference examples} \o \l{declarative/cppextensions/plugins}{Plugins} \o \l{declarative-cppextensions-qgraphicslayouts.html}{QGraphicsLayouts} \o \l{declarative/cppextensions/qwidgets}{QWidgets} @@ -148,7 +158,6 @@ For example, from your build directory, run: \list \o \l{declarative/toys/clocks}{Clocks} \o \l{declarative/toys/corkboards}{Corkboards} -\o \l{declarative/toys/dial}{Dial} \o \l{declarative/toys/dynamicscene}{Dynamic Scene} \o \l{declarative/toys/tic-tac-toe}{Tic Tac Toe} \o \l{declarative/toys/tvtennis}{TV Tennis} diff --git a/doc/src/declarative/globalobject.qdoc b/doc/src/declarative/globalobject.qdoc index 2885dd5..3a2ad81 100644 --- a/doc/src/declarative/globalobject.qdoc +++ b/doc/src/declarative/globalobject.qdoc @@ -49,7 +49,7 @@ Contains all the properties of the JavaScript global object, plus: \section1 Qt Object -The \l{qt-qml.html}{Qt object} provides useful enums and functions from Qt, for use in all QML +The \l{qml-qt.html}{Qt object} provides useful enums and functions from Qt, for use in all QML files. \section1 XMLHttpRequest diff --git a/doc/src/declarative/qtdeclarative.qdoc b/doc/src/declarative/qtdeclarative.qdoc index c47ab23..f7cb722 100644 --- a/doc/src/declarative/qtdeclarative.qdoc +++ b/doc/src/declarative/qtdeclarative.qdoc @@ -112,7 +112,7 @@ Returns the QML type id. - \sa qmlRegisterTypeNotAvailable + \sa qmlRegisterTypeNotAvailable() */ /*! @@ -147,7 +147,7 @@ fun.qml: Get back to work, slacker! Without this, a generic "Game is not a type" message would be given. - \sa qmlRegisterUncreatableType + \sa qmlRegisterUncreatableType() */ /*! diff --git a/doc/src/examples/qml-examples.qdoc b/doc/src/examples/qml-examples.qdoc index c2237d6..56ba1c7 100644 --- a/doc/src/examples/qml-examples.qdoc +++ b/doc/src/examples/qml-examples.qdoc @@ -271,6 +271,8 @@ This example displays a set of clocks with different times for different cities. Each clock is created by combining \l Image elements with \l Rotation transforms and \l SpringFollow animations. + + \image qml-clocks-example.png */ /*! @@ -280,14 +282,8 @@ This example presents a flickable set of interactive corkboards. It is created through a combination of elements like \l ListModel, \l Repeater and \l TextEdit together with rotation and scaling transforms, animation and mouse interaction. -*/ - -/*! - \title Toys: Dial - \example declarative/toys/dial - This example presents an interactive speedometer-type dial by combining - \l Image elements with \l Rotation transforms and \l SpringFollow animations. + \image qml-corkboards-example.png */ /*! @@ -297,6 +293,8 @@ This example presents an interactive drag-and-drop scene. It demonstrates how to use QML's \l{Dynamic Object Creation} support to dynamically create and destroy objects. + + \image qml-dynamicscene-example.png */ /*! @@ -304,6 +302,8 @@ \example declarative/toys/tic-tac-toe This example presents a simple implementation of Tic Tac Toe. + + \image qml-tic-tac-toe-example.png */ /*! @@ -312,6 +312,8 @@ This example shows how to use animation components such as \l SpringFollow, \l SequentialAnimation and \l PropertyAction to create a game of TV tennis. + + \image qml-tvtennis-example.png */ /*! @@ -329,10 +331,23 @@ */ /*! + \title UI Components: Dial + \example declarative/ui-components/dialcontrol + + This example presents an interactive speedometer-type dial by combining + \l Image elements with \l Rotation transforms and \l SpringFollow animations. + + \image qml-dialcontrol-example.png +*/ + + +/*! \title UI Components: Flipable \example declarative/ui-components/flipable This example shows how to use the Flipable element. + + \image qml-flipable-example.png */ /*! @@ -340,6 +355,8 @@ \example declarative/ui-components/progressbar This example shows how to create a progress bar. + + \image qml-progressbar-example.png */ /*! @@ -349,6 +366,8 @@ This example shows how to create scroll bars for a Flickable element using the \l {Flickable::visibleArea.xPosition}{Flickable::visibleArea} properties. + + \image qml-scrollbar-example.png */ /*! @@ -356,6 +375,8 @@ \example declarative/ui-components/searchbox This example shows how to create a search box. + + \image qml-searchbox-example.png */ /*! @@ -363,6 +384,8 @@ \example declarative/ui-components/slideswitch This example shows how to create a slide switch. + + \image qml-slideswitch-example.png */ /*! @@ -370,6 +393,8 @@ \example declarative/ui-components/spinner This example shows how to create a spinner-type component. + + \image qml-spinner-example.png */ /*! @@ -377,6 +402,8 @@ \example declarative/ui-components/tabwidget This example shows how to create a tab widget. + + \image qml-tabwidget-example.png */ /*! diff --git a/doc/src/examples/qml-flickr.qdoc b/doc/src/examples/qml-flickr.qdoc index ebf3250..43fcf1f 100644 --- a/doc/src/examples/qml-flickr.qdoc +++ b/doc/src/examples/qml-flickr.qdoc @@ -45,5 +45,5 @@ This demo shows how to write a mobile Flickr browser application in QML. - \image qml-flickr-example.png + \image qml-flickr-demo.png */ diff --git a/doc/src/examples/qml-minehunt.qdoc b/doc/src/examples/qml-minehunt.qdoc index 773f216..b2c662d 100644 --- a/doc/src/examples/qml-minehunt.qdoc +++ b/doc/src/examples/qml-minehunt.qdoc @@ -43,7 +43,8 @@ \title Minehunt \example demos/declarative/minehunt - This demo shows how to create a simple Minehunt game with QML and C++. + This demo shows how to create a simple Minehunt game, using QML for the + UI and a C++ plugin for the game logic. - \image qml-minehunt-example.png + \image qml-minehunt-demo.png */ diff --git a/doc/src/examples/qml-photoviewer.qdoc b/doc/src/examples/qml-photoviewer.qdoc index d1c3da2..d2114b9 100644 --- a/doc/src/examples/qml-photoviewer.qdoc +++ b/doc/src/examples/qml-photoviewer.qdoc @@ -45,5 +45,5 @@ This demo shows how to write a Flickr photo viewer application in QML. - \image qml-photoviewer-example.png + \image qml-photoviewer-demo.png */ diff --git a/doc/src/examples/qml-rssnews.qdoc b/doc/src/examples/qml-rssnews.qdoc index 0e7bdef..801efd9 100644 --- a/doc/src/examples/qml-rssnews.qdoc +++ b/doc/src/examples/qml-rssnews.qdoc @@ -45,5 +45,5 @@ This demo shows how to write a RSS news reader in QML. - \image qml-rssnews-example.png + \image qml-rssnews-demo.png */ diff --git a/doc/src/examples/qml-samegame.qdoc b/doc/src/examples/qml-samegame.qdoc index d9a9c7c..5b78b0c 100644 --- a/doc/src/examples/qml-samegame.qdoc +++ b/doc/src/examples/qml-samegame.qdoc @@ -43,7 +43,8 @@ \title Same Game \example demos/declarative/samegame - This demo shows how to write a Same Game in QML. + This demo shows how to write a 'Same Game' game in QML, using Javascript + for all the game logic. - \image qml-samegame-example.png + \image qml-samegame-demo.png */ diff --git a/doc/src/examples/qml-snake.qdoc b/doc/src/examples/qml-snake.qdoc index 373ca13..3125f2d 100644 --- a/doc/src/examples/qml-snake.qdoc +++ b/doc/src/examples/qml-snake.qdoc @@ -43,7 +43,8 @@ \title Snake \example demos/declarative/snake - This demo shows how to write a Snake game in QML. + This demo shows how to write a Snake game in QML, controlled by the + keyboard as well as the mouse. - \image qml-snake-example.png + \image qml-snake-demo.png */ diff --git a/doc/src/examples/qml-twitter.qdoc b/doc/src/examples/qml-twitter.qdoc new file mode 100644 index 0000000..0e66360 --- /dev/null +++ b/doc/src/examples/qml-twitter.qdoc @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +/*! + \title Twitter Mobile + \example demos/declarative/twitter + + This demo shows how to write a mobile Twitter client in QML. Use it to + tweet us(@qtbynokia) how much you like our demos! + + \image qml-twitter-demo.png +*/ diff --git a/doc/src/images/qml-clocks-example.png b/doc/src/images/qml-clocks-example.png Binary files differnew file mode 100644 index 0000000..1b352b5 --- /dev/null +++ b/doc/src/images/qml-clocks-example.png diff --git a/doc/src/images/qml-corkboards-example.png b/doc/src/images/qml-corkboards-example.png Binary files differnew file mode 100644 index 0000000..8acffa7 --- /dev/null +++ b/doc/src/images/qml-corkboards-example.png diff --git a/doc/src/images/qml-dialcontrol-example.png b/doc/src/images/qml-dialcontrol-example.png Binary files differnew file mode 100644 index 0000000..74cd645 --- /dev/null +++ b/doc/src/images/qml-dialcontrol-example.png diff --git a/doc/src/images/qml-dynamicscene-example.png b/doc/src/images/qml-dynamicscene-example.png Binary files differnew file mode 100644 index 0000000..1f725d1 --- /dev/null +++ b/doc/src/images/qml-dynamicscene-example.png diff --git a/doc/src/images/qml-flickr-example.png b/doc/src/images/qml-flickr-demo.png Binary files differindex 71ea567..71ea567 100644 --- a/doc/src/images/qml-flickr-example.png +++ b/doc/src/images/qml-flickr-demo.png diff --git a/doc/src/images/qml-flipable-example.png b/doc/src/images/qml-flipable-example.png Binary files differnew file mode 100644 index 0000000..dd68a66 --- /dev/null +++ b/doc/src/images/qml-flipable-example.png diff --git a/doc/src/images/qml-minehunt-example.png b/doc/src/images/qml-minehunt-demo.png Binary files differindex 3b69569..3b69569 100644 --- a/doc/src/images/qml-minehunt-example.png +++ b/doc/src/images/qml-minehunt-demo.png diff --git a/doc/src/images/qml-photoviewer-example.png b/doc/src/images/qml-photoviewer-demo.png Binary files differindex be6f1bf..be6f1bf 100644 --- a/doc/src/images/qml-photoviewer-example.png +++ b/doc/src/images/qml-photoviewer-demo.png diff --git a/doc/src/images/qml-progressbar-example.png b/doc/src/images/qml-progressbar-example.png Binary files differnew file mode 100644 index 0000000..3ddd6c6 --- /dev/null +++ b/doc/src/images/qml-progressbar-example.png diff --git a/doc/src/images/qml-rssnews-example.png b/doc/src/images/qml-rssnews-demo.png Binary files differindex 948ef4d..948ef4d 100644 --- a/doc/src/images/qml-rssnews-example.png +++ b/doc/src/images/qml-rssnews-demo.png diff --git a/doc/src/images/qml-samegame-example.png b/doc/src/images/qml-samegame-demo.png Binary files differindex c17b4e0..c17b4e0 100644 --- a/doc/src/images/qml-samegame-example.png +++ b/doc/src/images/qml-samegame-demo.png diff --git a/doc/src/images/qml-searchbox-example.png b/doc/src/images/qml-searchbox-example.png Binary files differnew file mode 100644 index 0000000..97d12bb --- /dev/null +++ b/doc/src/images/qml-searchbox-example.png diff --git a/doc/src/images/qml-slideswitch-example.png b/doc/src/images/qml-slideswitch-example.png Binary files differnew file mode 100644 index 0000000..17cb3eb --- /dev/null +++ b/doc/src/images/qml-slideswitch-example.png diff --git a/doc/src/images/qml-snake-example.png b/doc/src/images/qml-snake-demo.png Binary files differindex d3c077d..d3c077d 100644 --- a/doc/src/images/qml-snake-example.png +++ b/doc/src/images/qml-snake-demo.png diff --git a/doc/src/images/qml-spinner-example.png b/doc/src/images/qml-spinner-example.png Binary files differnew file mode 100644 index 0000000..ed381f8 --- /dev/null +++ b/doc/src/images/qml-spinner-example.png diff --git a/doc/src/images/qml-tabwidget-example.png b/doc/src/images/qml-tabwidget-example.png Binary files differnew file mode 100644 index 0000000..05887f3 --- /dev/null +++ b/doc/src/images/qml-tabwidget-example.png diff --git a/doc/src/images/qml-tic-tac-toe-example.png b/doc/src/images/qml-tic-tac-toe-example.png Binary files differnew file mode 100644 index 0000000..5a5cc82 --- /dev/null +++ b/doc/src/images/qml-tic-tac-toe-example.png diff --git a/doc/src/images/qml-tvtennis-example.png b/doc/src/images/qml-tvtennis-example.png Binary files differnew file mode 100644 index 0000000..ac2b527 --- /dev/null +++ b/doc/src/images/qml-tvtennis-example.png diff --git a/doc/src/images/qml-twitter-demo.png b/doc/src/images/qml-twitter-demo.png Binary files differnew file mode 100644 index 0000000..63d6486 --- /dev/null +++ b/doc/src/images/qml-twitter-demo.png 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 new file mode 100644 index 0000000..6735c6c --- /dev/null +++ b/doc/src/snippets/declarative/texteditor.qml @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** 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 + +//![0] +Flickable { + id: flick + + width: 300; height: 200; + contentWidth: edit.paintedWidth + contentHeight: edit.paintedHeight + clip: true + + function ensureVisible(r) + { + if (contentX >= r.x) + contentX = r.x; + else if (contentX+width <= r.x+r.width) + contentX = r.x+r.width-width; + if (contentY >= r.y) + contentY = r.y; + else if (contentY+height <= r.y+r.height) + contentY = r.y+r.height-height; + } + + TextEdit { + id: edit + width: flick.width + height: flick.height + focus: true + wrapMode: TextEdit.Wrap + onCursorRectangleChanged: flick.ensureVisible(cursorRectangle) + } +} +//![0] 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> |