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
New Contributor
Posts: 3
Registered: ‎10-21-2013
My Device: Dev AlphaB
My Carrier: TruemoneH

Please suggest about pass value between 2 qml

[ Edited ]

Hi all,

 

If I have main.qml and calculate some number in that and store in "Current.text"

How to show value of Current.text in another qml (for example secondpage.qml)

These two qml files in same project.

 

Thanks for your advices.

Regular Contributor
Posts: 56
Registered: ‎06-25-2012
My Device: non-blackberry user
My Carrier: Airtel

Re: Please suggest about pass value between 2 qml

Hello penpen,

 

welcome to the forum Smiley Happy

 

Now the approach i use for this problem is declaring a property in the root item of your application , this can be a navigationpane or something else.

 

Then you can assign the value to the declared property and then access it any where in the application , i.e. in all qml files !!

 

Let me know if you are not clear with this !!

 

Cheers,

Neo

New Contributor
Posts: 3
Registered: ‎10-21-2013
My Device: Dev AlphaB
My Carrier: TruemoneH

Re: Please suggest about pass value between 2 qml

Hi Coolneo,

 

Thanks for your advice.

 

For main.qml I used Navigation pane. 

 

If you think of pre-script that generate when I selected create new project with Navigation pane.

It will generate 2 qml files. main and secondpage.qml  right?

 

When I create fomular in main.qml and need to use result in secondpage.qml .. can I do that?

 

Thanks

Regular Contributor
Posts: 56
Registered: ‎06-25-2012
My Device: non-blackberry user
My Carrier: Airtel

Re: Please suggest about pass value between 2 qml

yes of cource you can do that let me show you :

 

main.qml

 

NavigationPane {

id:root

property string buttonText

 

Page {


Container {

Button {

text:'pageonebutton'

 

onClicked:{

root.buttonText = "something"

// push second page here

}

}

}

}

 

}

 

 

SecondPage.qml

 

Page {

 

onCreationComplete {

console.log(root.buttonText)

}

}

 

This is an hand written code can have some syntax issues !!

Highlighted
New Contributor
Posts: 3
Registered: ‎10-21-2013
My Device: Dev AlphaB
My Carrier: TruemoneH

Re: Please suggest about pass value between 2 qml

Thanks a lot for your response. I'll try and let's you know for the result.

 

Thanks