c++ - Cascades NavigationPane: connect to an object signal into another qml file -


i've created blackberry application using wizard navigationpane template, , added components on detailspage.qml (like button , textfield).

i want connect slot function on button in detailspage.qml, when clicked read text textarea on same page.

my problem when application launched, qml loaded main.qml. if try reference object on detailspage.qml findchild return 0x0, because cannot find it. main.qml file is:

// navigation pane project template import bb.cascades 1.0  navigationpane {     id: navigationpane     page {         // page picture thumbnail         container {             background: color.black             layout: docklayout {             }             button {                                 horizontalalignment: horizontalalignment.center                 verticalalignment: verticalalignment.center                 text: qstr("new todo")                 imagesource: "asset:///images/picture1thumb.png"                 onclicked: {                     // show detail page when button 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                         objectname: "secondpagedefinition"                         source: "detailspage.qml"                     }                 ]             }         }     }     oncreationcompleted: {         // slot called when declarative scene created         // write post creation initialization here         console.log("navigationpane - oncreationcompleted()");          // enable layout adapt device rotation         // don't forget enable screen rotation in bar-bescriptor.xml (application->orientation->auto-orient)         orientationsupport.supporteddisplayorientation = supporteddisplayorientation.all;     } } 

the detailspage.qml file is:

// navigation pane project template import bb.cascades 1.0  page {     // page picture detail     id: pgdetail     objectname: "pgdetail"     actions: [         // create navigation panel actions here         actionitem {             title: qstr("break")             ontriggered: {                 imgview.imagesource = "asset:///images/picture1br.png"             }         }     ]     paneproperties: navigationpaneproperties {         backbutton: actionitem {             ontriggered: {                 // define happens when button pressed here                 // in case closed detail page                 navigationpane.pop()             }         }     }     container {         background: color.black         label {             text: qstr("page 2")             horizontalalignment: horizontalalignment.center             textstyle {                 base: systemdefaults.textstyles.titletext                 color: color.yellow             }         }         imageview {             id: imgview             imagesource: "asset:///images/picture1.png"             horizontalalignment: horizontalalignment.center         }         label {             text: qstr("picture description")             horizontalalignment: horizontalalignment.center         }         textarea {             objectname: "notetext"         }         button {             objectname: "insertbtn"             text: qstr("insert note")         }     } } 

i tried connect button using signal pushtransactionended, has 2 problems:

  1. the connect method called every time change screen (and want connect slot on startup).
  2. when button clicked, have same problem, have no reference currentpage (but maybe if save root pane in case, using top() method, can obtain access current page)

so questions are: when must connect slot signal? how that, if objects on different qml file?

i want handle clicked event on c++ not directly in qml file.

register c++ object containing slot qml using setcontextproperty , call slot directly detailspage.qml

    ...     button {          objectname: "insertbtn"         text: qstr("insert note")         onclicked:{              cppobject.myslot()         }     }     ... 

Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -