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

Posts: 188
Registered: ‎04-07-2013
My Device: BlackBerry Z10
My Carrier: Telus

Create a Page in a Separate CPP file and initialize it..

Hi, how do we create a Page in a separate c++ class?


I have an AppName.CPP that has a NavigationPane and I would like to create a Page in a separate CPP file, and later initialize this Page from my AppName.CPP.


Any thoughts on how to do this?


Posts: 19
Registered: ‎07-02-2013
My Device: BlackBerry Q10
My Carrier: Telus

Re: Create a Page in a Separate CPP file and initialize it..

In your separate CPP file create your page, and have a "getPage()" method that you return a pointer to this Page.


AppName.cpp will now use this getPage() method to get a reference to the page and set it to the application scene, as well as modify it any way it needs to.


However, be careful with the ownership models here. Read up here:



If the Page doesn't already have a parent the Application will attempt to take ownership of the page. If that page is ever popped off the stack, your separate CPP file might be pointing to garbage memory and start causing crashes!