diff options
author | David Boddie <dboddie@trolltech.com> | 2010-06-16 10:44:02 (GMT) |
---|---|---|
committer | David Boddie <dboddie@trolltech.com> | 2010-06-16 10:44:02 (GMT) |
commit | 9e7f0b9e45cef278c8874539257b4038a0aa6615 (patch) | |
tree | 6f66ec8ea599e348ea550da76612cb3873478a21 /doc/src/snippets/declarative/listmodel-modify.qml | |
parent | 700a4826cf6bd755df000cb16c259343efb695cd (diff) | |
parent | 5b5785bc564ccea9f6868d02be3d1080cb5039b9 (diff) | |
download | Qt-9e7f0b9e45cef278c8874539257b4038a0aa6615.zip Qt-9e7f0b9e45cef278c8874539257b4038a0aa6615.tar.gz Qt-9e7f0b9e45cef278c8874539257b4038a0aa6615.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7
Diffstat (limited to 'doc/src/snippets/declarative/listmodel-modify.qml')
-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 +} + +} |