2

How to pass a data (ex userid ) from one page to another page in blackberry 10 qml ?

SelvaRaman
  • 218
  • 2
  • 15

2 Answers2

5

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")
Nishant Shah
  • 1,590
  • 1
  • 15
  • 25
  • I'm trying to access a function on home page from my main page which has a navigation pane and on poptransition I need to call a method on homepage and I tried as per your method but didnt work. It shows targetPageid not found. I have declared targetPageid as homepage id. Do I have to include anything else to access it on my main page? – Francis F Dec 22 '14 at 11:43
0

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
    }      
parakmiakos
  • 2,994
  • 9
  • 29
  • 43
Mokgadi
  • 1
  • 1