summaryrefslogtreecommitdiffstats
path: root/examples/declarative/tabwidget/TabWidget.qml
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-11-23 01:38:16 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-11-23 01:38:16 (GMT)
commit4621721a9c3705dc9fbc3b6f15e6122f913e5c72 (patch)
treebba2e8030ddd2586f5a634496736c6b4c221ca6c /examples/declarative/tabwidget/TabWidget.qml
parent60e39093e9bd76b88027863d60873bc82492be50 (diff)
downloadQt-4621721a9c3705dc9fbc3b6f15e6122f913e5c72.zip
Qt-4621721a9c3705dc9fbc3b6f15e6122f913e5c72.tar.gz
Qt-4621721a9c3705dc9fbc3b6f15e6122f913e5c72.tar.bz2
Demonstrate "container" type objects.
Diffstat (limited to 'examples/declarative/tabwidget/TabWidget.qml')
-rw-r--r--examples/declarative/tabwidget/TabWidget.qml42
1 files changed, 42 insertions, 0 deletions
diff --git a/examples/declarative/tabwidget/TabWidget.qml b/examples/declarative/tabwidget/TabWidget.qml
new file mode 100644
index 0000000..c56f41e
--- /dev/null
+++ b/examples/declarative/tabwidget/TabWidget.qml
@@ -0,0 +1,42 @@
+import Qt 4.6
+
+Item {
+ id: page
+ property int current: 0
+ default property alias content: stack.children
+ onCurrentChanged: setOpacities()
+ Component.onCompleted: setOpacities()
+ function setOpacities()
+ {
+ for (var i=0; i<stack.children.length; ++i) {
+ stack.children[i].opacity = i==current ? 1 : 0
+ }
+ }
+ Row {
+ id: header
+ Repeater {
+ delegate:
+ Rectangle {
+ width: page.width / stack.children.length
+ height: 15
+ color: page.current == index ? "grey" : "lightGrey"
+ Text {
+ anchors.fill: parent
+ text: stack.children[index].title
+ elide: Text.ElideRight
+ }
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: page.current = index
+ }
+ }
+ model: stack.children.length
+ }
+ }
+ Item {
+ id: stack
+ anchors.top: header.bottom
+ anchors.bottom: page.bottom
+ width: page.width
+ }
+}