diff options
Diffstat (limited to 'examples/declarative/modelviews/package')
-rw-r--r-- | examples/declarative/modelviews/package/Delegate.qml | 48 | ||||
-rw-r--r-- | examples/declarative/modelviews/package/package.qmlproject | 16 | ||||
-rw-r--r-- | examples/declarative/modelviews/package/view.qml | 35 |
3 files changed, 99 insertions, 0 deletions
diff --git a/examples/declarative/modelviews/package/Delegate.qml b/examples/declarative/modelviews/package/Delegate.qml new file mode 100644 index 0000000..785fde6 --- /dev/null +++ b/examples/declarative/modelviews/package/Delegate.qml @@ -0,0 +1,48 @@ +import Qt 4.7 + +//![0] +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 } + } + } + ] + } +} +//![0] diff --git a/examples/declarative/modelviews/package/package.qmlproject b/examples/declarative/modelviews/package/package.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/modelviews/package/package.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/modelviews/package/view.qml b/examples/declarative/modelviews/package/view.qml new file mode 100644 index 0000000..67f896b --- /dev/null +++ b/examples/declarative/modelviews/package/view.qml @@ -0,0 +1,35 @@ +import Qt 4.7 + +Item { + width: 400 + height: 200 + + ListModel { + id: myModel + ListElement { display: "One" } + ListElement { display: "Two" } + ListElement { display: "Three" } + ListElement { display: "Four" } + ListElement { display: "Five" } + ListElement { display: "Six" } + ListElement { display: "Seven" } + ListElement { display: "Eight" } + } + //![0] + 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 + } + //![0] +} |