diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-06-11 00:15:09 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-06-11 00:15:09 (GMT) |
commit | 81fba1a0ed8dda1b0dfc1051cbcca751c4017648 (patch) | |
tree | df4786a4265a88bcded900013e25dadf05caa3d6 | |
parent | 90786cb0d8dd8da2cc53258c93c0129f7c4095fc (diff) | |
parent | 3b15102a287c48bb6766acf49c61471abe003bef (diff) | |
download | Qt-81fba1a0ed8dda1b0dfc1051cbcca751c4017648.zip Qt-81fba1a0ed8dda1b0dfc1051cbcca751c4017648.tar.gz Qt-81fba1a0ed8dda1b0dfc1051cbcca751c4017648.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
-rw-r--r-- | doc/src/snippets/declarative/listmodel-modify.qml | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/doc/src/snippets/declarative/listmodel-modify.qml b/doc/src/snippets/declarative/listmodel-modify.qml new file mode 100644 index 0000000..03fb314 --- /dev/null +++ b/doc/src/snippets/declarative/listmodel-modify.qml @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** 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: 200; height: 200 + +ListModel { + id: fruitModel + + ListElement { + name: "Apple" + cost: 2.45 + attributes: [ + ListElement { description: "Core" }, + ListElement { description: "Deciduous" } + ] + } + ListElement { + name: "Orange" + cost: 3.25 + attributes: [ + ListElement { description: "Citrus" } + ] + } + ListElement { + name: "Banana" + cost: 1.95 + attributes: [ + ListElement { description: "Tropical" }, + ListElement { description: "Seedless" } + ] + } +} + +//![delegate] + Component { + id: fruitDelegate + Item { + width: 200; height: 50 + Text { text: name } + Text { text: '$' + cost; anchors.right: parent.right } + + // Double the price when clicked. + MouseArea { + anchors.fill: parent + onClicked: fruitModel.setProperty(index, "cost", cost * 2) + } + } + } +//![delegate] + +ListView { + width: 200; height: 200 + model: fruitModel + delegate: fruitDelegate +} + +} |