Package provides a collection of named items. More...
The Package class is used in conjunction with VisualDataModel to enable delegates with a shared context to be provided to multiple views.
Any item within a Package may be assigned a name via the Package.name attached property.
The example below creates a Package containing two named items; list and grid. The third element in the package (the Rectangle) is parented to whichever delegate it should appear in. This allows an item to move between views.
Package { Text { id: listDelegate; width: 200; height: 25; text: 'Empty'; Package.name: 'list' } Text { id: gridDelegate; width: 100; height: 50; text: 'Empty'; Package.name: 'grid' } Rectangle { id: wrapper width: 200; height: 25 color: 'lightsteelblue' Text { text: display; anchors.centerIn: parent } MouseArea { anchors.fill: parent onClicked: { if (wrapper.state == 'inList') wrapper.state = 'inGrid'; else wrapper.state = 'inList'; } } state: 'inList' states: [ State { name: 'inList' ParentChange { target: wrapper; parent: listDelegate } }, State { name: 'inGrid' ParentChange { target: wrapper; parent: gridDelegate x: 0; y: 0; width: gridDelegate.width; height: gridDelegate.height } } ] transitions: [ Transition { ParentAnimation { NumberAnimation { properties: 'x,y,width,height'; duration: 300 } } } ] } }
These named items are used as the delegates by the two views who reference the special VisualDataModel::parts property to select a model which provides the chosen delegate.
VisualDataModel { id: visualModel delegate: Delegate {} model: myModel } ListView { width: 200; height:200 model: visualModel.parts.list } GridView { x: 200; width: 200; height:200 cellHeight: 50 model: visualModel.parts.grid }
See also Package example, Photo Viewer demo, and QtDeclarative.
read-onlyPackage.name : string |
This attached property holds the name of an item within a Package.
© 2008-2011 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide.
All other trademarks are property of their respective owners. Privacy Policy
Licensees holding valid Qt Commercial licenses may use this document in accordance with the Qt Commercial License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Nokia.
Alternatively, this document may be used under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.