main.qml Example File
loader/assets/main.qml
import bb.cascades 1.0
import Utils 1.0
import QtQuick 1.0 as QtBase
TabbedPane {
Tab {
title: qsTr ("External")
Page {
Container {
layout: DockLayout {}
ImageView {
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill
imageSource: "asset:///images/background.png"
}
Container {
id: pageContainer
property variant pageNames: ['', 'Page1.qml', 'Page2.qml', 'Page3.qml', 'Page4.qml', 'Page5.qml']
horizontalAlignment: HorizontalAlignment.Center
verticalAlignment: VerticalAlignment.Center
Loader {
horizontalAlignment: HorizontalAlignment.Center
source: pageContainer.pageNames[Math.round(slider.immediateValue)]
}
Slider {
id: slider
topMargin: 50
fromValue: 0
toValue: 5
value: 0
}
}
}
}
}
Tab {
title: qsTr ("Internal")
Page {
attachedObjects: [
QtBase.Component {
id: redSquare
ColoredRectangle {
property string colorName: qsTr ("red")
color: Color.Red
title: qsTr ("Red")
}
},
QtBase.Component {
id: greenSquare
ColoredRectangle {
property string colorName: qsTr ("green")
color: Color.Green
title: qsTr ("Green")
}
},
QtBase.Component {
id: blueSquare
ColoredRectangle {
property string colorName: qsTr ("blue")
color: Color.Blue
title: qsTr ("Blue")
}
},
QtBase.Component {
id: yellowSquare
ColoredRectangle {
property string colorName: qsTr ("yellow")
color: Color.Yellow
title: qsTr ("Yellow")
}
}
]
Container {
layout: DockLayout {}
ImageView {
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill
imageSource: "asset:///images/background.png"
}
Container {
horizontalAlignment: HorizontalAlignment.Center
verticalAlignment: VerticalAlignment.Center
Label {
horizontalAlignment: HorizontalAlignment.Center
text: qsTr ("Touch the rectangle below")
textStyle.color: Color.White
}
Loader {
id: rectLoader
property int counter: 0
horizontalAlignment: HorizontalAlignment.Center
topMargin: 10
sourceComponent: counter == 0 ? redSquare
: counter == 1 ? greenSquare
: counter == 2 ? blueSquare
: yellowSquare
onTouch: {
if (event.isDown()) {
counter = ((counter + 1) % 4)
}
}
}
Label {
horizontalAlignment: HorizontalAlignment.Center
topMargin: 10
text: qsTr ("Selected color: %1").arg(rectLoader.control ? rectLoader.control.colorName : qsTr("n/a"))
textStyle {
base: SystemDefaults.TextStyles.BodyText
color: Color.White
}
}
}
}
}
}
}