Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Highlighted
Developer
Posts: 209
Registered: ‎05-08-2012
My Device: PlayBook 64 Gb and Z10 LE
My Carrier: Vodafone

Connect signal from two qml file

Hi my friend ask me for an easy sample for connecting the signal from option in (main.qml) to another qml file in the Project and call a function with different data.

this is a source code Smiley Happy .. I hope to help another people with this proplem (I think don't existing big o little problem but I think help all new developers)

 

The Code:

 

MAIN.QML

 

import bb.cascades 1.0

NavigationPane {
id: navigationPane
Page {
id: page1

// page with a picture thumbnail
Container {
id: root

background: Color.Yellow
layout: DockLayout {
}
function calcoloSomma(fahr,zukka) {
if (zukka == true) return ((fahr - 100) - ((fahr - 100) / 100) * 5).toFixed(1);
return ((fahr - 104) - ((fahr - 104) / 100) * 5).toFixed(1);
}
RadioGroup {
id:radio1
objectName:radio1
Option {
id: opt1
objectName: opt1

onSelectedChanged: {
bottone.enabled = true
}
text: "opt1"
}
Option {
id: opt2
objectName: opt2

onSelectedChanged: {
bottone.enabled = true
}
text :  "opt2"
}
}
Button {
id: bottone
horizontalAlignment: HorizontalAlignment.Center
verticalAlignment: VerticalAlignment.Center
text: qsTr("Pagina 2")
imageSource: "asset:///images/picture1thumb.png"
onClicked: {
// show detail page when the button is clicked
var page = getSecondPage();
console.debug("pushing detail " + page)
navigationPane.push(page);
}
property Page secondPage
function getSecondPage() {
if (! secondPage) {
secondPage = secondPageDefinition.createObject();
}
return secondPage;
}
attachedObjects: [
ComponentDefinition {
id: secondPageDefinition
source: "DetailsPage.qml"
}
]
enabled: false
}
}
}
onCreationCompleted: {
// this slot is called when declarative scene is created
// write post creation initialization here
console.log("NavigationPane - onCreationCompleted()");

// enable layout to adapt to the device rotation
// don't forget to enable screen rotation in bar-bescriptor.xml (Application->Orientation->Auto-orient)
OrientationSupport.supportedDisplayOrientation = SupportedDisplayOrientation.All;
}
}

 

DETAILSPAGE.QML

 

import bb.cascades 1.0

Page {
// page with a picture detail
id: pgDetail
actions: [
// create navigation panel actions here
ActionItem {
title: qsTr("Break")
onTriggered: {
// imgageView.imageSource = "asset:///images/picture1br.png"
}
}
]
paneProperties: NavigationPaneProperties {
backButton: ActionItem {
onTriggered: {
// define what happens when back button is pressed here
// in this case is closed the detail page
navigationPane.pop()
}
}
}
Container {
Label {
id: label1
text : "80"
}
Label {
id:label2

text: root.calcoloSomma (label1.text,opt1.selected);
horizontalAlignment: HorizontalAlignment.Center
textStyle {
base: SystemDefaults.TextStyles.TitleText

}
}
}
}

_______________________________________________

If U like my post click on LIKE Smiley Wink