09-10-2012 11:11 PM - edited 09-10-2012 11:11 PM
Hi,
I am trying out the NavigationPane with 2 pages. In the first page, I collects some values (via text fields, slider etc). After the user fills in all the values and click the "calculate" button, the second page will be pushed to the screen to display the results based on what the user entered before.
The way I am doing it right now is by storing the values from the "first" page into some global variables in a javascript file. The second page will then read from these variables and perform the necessary calculation.
First page:
import bb.cascades 1.0
import "ExtJS.js" as MortgageCal
NavigationPane {
id: navPane
Page {
content: Container {
id: mortgagePaymentSettingPage
Container {
TextField {
inputMode: TextFieldInputMode.PhoneNumber
id: valueTxt
onTextChanged: {
ExtJS.Value = Math.round(text)
}
}
}
}
actions: [
ActionItem {
title: "Calculate"
ActionBar.placement: ActionBarPlacement.OnBar
onTriggered: {
navPane.deprecatedPushQmlByString("resultPage.qml" );
}
}
]
}
}
Second page:
import bb.cascades 1.0
import "ExtJS.js" as MortgageCal
Page {
content: Container {
id: ResultPage
Container {
Label {
text: "User Entered: " + ExtJS.Value
}
}
}
}
I am wondering if there is a better alternative to make the values from the first page "visiable" to the second page?
Thanks,
Solved! Go to Solution.
09-11-2012 12:58 AM - edited 09-11-2012 12:58 AM
Hi,
solution is very simple . You can access valueTxt.text property in resultPage.qml like same qml.
when you write valueTxt in second page and put a dot , it will not give suggetion , you have to write manually.
when you compile it will work completely .
You can only access first qml varibale when second page is pushed by navigation pane .
Try this,
main.qml
import bb.cascades 1.0
NavigationPane {
id: navPane
Page {
content: Container {
id: mortgagePaymentSettingPage
Container {
TextField {
inputMode: TextFieldInputMode.PhoneNumber
id: valueTxt
}
}
}
actions: [
ActionItem {
title: "Calculate"
ActionBar.placement: ActionBarPlacement.OnBar
onTriggered: {
navPane.deprecatedPushQmlByString("resultPage.qml" );
}
}
]
}
}
resultPage.qml
import bb.cascades 1.0
Page {
content: Container {
Label {
text: " I am First page Text : " + valueTxt.text
}
}
}
09-11-2012 01:15 AM
Thanks! It works
09-11-2012 02:04 PM
12-11-2012 06:32 PM
What if a page is pushed by navigationPane, and the variable is entered on the pushed page. Can that variable be seen by subsequent pushed pages?
In other words is there a way to make a variable available to all the pages in a stack no matter which page it is entered on?
12-15-2012 05:49 PM
I actually solved my own question.
On NavigationPane one can make a variable global by referencing Qt. In this case.
NavigationPane{
id:navPane
Page{
onCreationCompleted:{
Qt.labelpage1=labelpage1;}
Container{
Label{
id:labelpage1
text:"Hello there"}...
//
labelpage1 can then be referenced on other pages as:
Label{
id
age2referencelabel
text:"Here is the entered text: " +Qt.labelpage1.text;
}