1

I'm new to Blackberry 10 dev. So I'm wondering what's the best way to do this as I'm not getting any clear answers from the dev docs.

What I want is to start a separate view in my app from a navigation screen. The new page will then create a http request and update the UI based on the output.

The best way seems to be using the NavigationPane and add a qml view. However how do I invoke a C++ function when it's pushed onto the stack? Something similar to android onActivityCreated() in Fragments. There is the Http example docs, but the program started the http request from the constructor of the inherited QObject. How to I have a function executed as the new qml is added to the navigation stack as

 // navigationpane.qml

NavigationPane {
    id: navigationPane
    Page {
        Container {
            Label { 
                text: "First page"
            }
        }

        actions: [
            ActionItem {
                title: "Next page"
                ActionBar.placement: ActionBarPlacement.OnBar
                onTriggered: {
                    var page = pageDefinition.createObject();
                    navigationPane.push(page);
                }

                attachedObjects: ComponentDefinition {
                    id: pageDefinition;
                    source: "secondpage.qml"
                }
            }
        ]
    }
    onPopTransitionEnded: { page.destroy(); }
}
sinkpoint
  • 71
  • 4

2 Answers2

3

I think the onCreationCompleted function may be what you're looking for.

In the Page object of your secondpage.qml file, add this:

Page {
        id: secondpage

        onCreationCompleted: {
            // use Javascript to call the exposed C++ function
        }
    }
tcdowney
  • 317
  • 2
  • 5
0

If you want something more in the spirit of "onActivityCreated()", you can use the signal transitionEnded:

    NavigationPane { 
         onPushTransitionEnded{
             top.callYourPageFunction();
        }
    }
Benoit
  • 1,922
  • 16
  • 25