Reputation: 218
How to pass a data (ex userid ) from one page to another page in blackberry 10 qml ?
Upvotes: 2
Views: 1367
Reputation: 1
Create an object in your cpp
qml->setContextProperty("MyApp",this);
And then call the method using this object. i called a method in a button in my main.qml
Button{
id : button
text : "Connect"
onClicked:
{
MyApp.PostData("46565652","sotho")
}
horizontalAlignment: HorizontalAlignment.Center
}
Upvotes: 0
Reputation: 1586
You can either create property on target page or create a java script function to do so. If you want to validate or perform any other operation before assigning you should use java script function.
Page {
//targetPage
property string userid //you can also use alias here
function initialize(id) {
userid = id
//you can also set property of controls here
}
}
Call it on your page like this
targetPageid.userid = "user id"
OR
targetPageid.initialize("user id")
Upvotes: 5