Post on 21-Nov-2015
description
Experiment 4
Main.qml// Default empty project templateimport bb.cascades 1.0
// creates one page with a labelPage { function createPostcard(){ var r=Math.ceil(Math.random()*3) switch(r){ case 1: postcard.image="malmo.jpg" postcard.text="Greetings from Malmo!" break case 2: postcard.image = "rome.jpg" postcard.text = "Greetings from Rome!" break case 3: postcard.image = "waterloo.jpg" postcard.text = "Greetings from Waterloo!" break default: postcard.image = "default.jpg" postcard.text = "Greetings from Kerela!" break } postcard.rotationZ=(Math.random()*20)-10 var s = Math.random()*0.5+0.7 postcard.scaleX=s postcard.scaleY=s
} Container { layout: StackLayout { orientation: LayoutOrientation.TopToBottom
}
background: Color.DarkGray Container { layout: StackLayout {
} layoutProperties: StackLayoutProperties { spaceQuota: 1.0
} horizontalAlignment: HorizontalAlignment.Fill Button { id: mybutton horizontalAlignment: HorizontalAlignment.Fill text: "Create" signal changePostcard() onClicked: { mybutton.changePostcard.connect(createPostcard()) mybutton.changePostcard() } }
} Container { layout: DockLayout {
} layoutProperties: StackLayoutProperties { spaceQuota: 7.0
} verticalAlignment: VerticalAlignment.Fill horizontalAlignment: HorizontalAlignment.Fill PostCardView{ id: postcard horizontalAlignment: HorizontalAlignment.Center verticalAlignment: VerticalAlignment.Center
}
}
}}
PostcardView.qml import bb.cascades 1.0
Container { property alias image: myimage.imageSource property alias text: mytext.text layout: AbsoluteLayout {
} ImageView { imageSource: "asset:///overlay.jpg"
} ImageView { id: myimage layoutProperties: AbsoluteLayoutProperties { positionX: 14.0 positionY: 14.0
} imageSource: "asset:///default.jpg"
} TextArea { id: mytext layoutProperties: AbsoluteLayoutProperties { positionX: 20.0 positionY: 20.0
} text: "Greetings" backgroundVisible: false editable: false textStyle.color: Color.Black
}
}