Welcome!

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

Reply
Super Contributor
Posts: 440
Registered: ‎01-13-2011
My Device: Playbook
My Carrier: NA

Switching pages with a menu?

[ Edited ]

I have two classes in my app, Kit and Settings. In each class is a page called root.

 

At the start of my app I intialise each class and set the scene to kit.

 

.h
Kit *kit;
Settings *settings;

.cpp
kit = new kit();
settings = new Settings();
 
Application::instance()->setScene(kit->root);

 Then I create my menu:

 

 Menu *menu = new Menu;
 ActionItem *actionOne = ActionItem::create().title("Kit");
 ActionItem *actionTwo = ActionItem::create().title("Settings");
	
 menu->addAction(actionOne);
 menu->addAction(actionTwo);
 bool res = QObject::connect(actionOne, SIGNAL(triggered()), this, SLOT(handleAction1()));
 res = QObject::connect(actionTwo, SIGNAL(triggered()), this, SLOT(handleAction2()));
 Q_ASSERT(res);
 Q_UNUSED(res);

 And here is how each menu press is handled:

 

void App::handleAction1()
{

	Application::instance()->setScene(kit->root);

}

void App::handleAction2()
{
	Application::instance()->setScene(settings->root);
}

 

The problem is, the app starts on kit, then I click on settings and it switches to the settings page, then I click back to kit and it crashes.

 

Anyone know whats going wrong?

--------------------------------------------------------------------------------------------------
BlackBerry Apps: Instruments | ARTPAD | Piano | Drums | Xylophone
Super Contributor
Posts: 440
Registered: ‎01-13-2011
My Device: Playbook
My Carrier: NA

Re: Switching pages with a menu?

Anyone?

--------------------------------------------------------------------------------------------------
BlackBerry Apps: Instruments | ARTPAD | Piano | Drums | Xylophone
Developer
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: Switching pages with a menu?

Try to change to

void App::handleAction1()
{
        int i = 0;
	Application::instance()->setScene(kit->root);

}

and set up breakpoint to "int i = 0;"

This way you'll at least know when it crashes - before ->setScene called or after.

 

Super Contributor
Posts: 440
Registered: ‎01-13-2011
My Device: Playbook
My Carrier: NA

Re: Switching pages with a menu?

It crashes on setScene.

 

No source available for "0x794dd842" 

 

Any ideas?

--------------------------------------------------------------------------------------------------
BlackBerry Apps: Instruments | ARTPAD | Piano | Drums | Xylophone
Developer
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: Switching pages with a menu?

Nothing comes to my mind...

Why do you use instance() btw? I see in examples

Application.setScene(...
Highlighted
Super Contributor
Posts: 440
Registered: ‎01-13-2011
My Device: Playbook
My Carrier: NA

Re: Switching pages with a menu?

Becuase that doesnt work, the examples are incorrect.

--------------------------------------------------------------------------------------------------
BlackBerry Apps: Instruments | ARTPAD | Piano | Drums | Xylophone