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
New Contributor
Vin_s
Posts: 5
Registered: ‎11-16-2012
My Device: BB10 DevAlpha

BB10 Pages navigation issues

Hi,

 

I am new in BB10 development and I try to make a simple app in C++.

Basically, three pages are stacked in a NavigationPane, each one contains a label and a button that pushes the next page. I based my code on the example "Creating a stack of screens" provided by BB10. My problem is that going from the first to second page works fine, but not from the second to the third. I also tried to put the creation of my pages in separated functions, and then now works anymore :smileysad:

 

So my problem is double : I'd like to know what is wrong in my functions and makes them not work, and  what is wrong in the connection of the slot and signal of the second page's button for it not to load the third page.

 

My code :

 

Quizz.cpp

#include "Quizz.hpp"

Quizz::Quizz(bb::cascades::Application *app)
: QObject(app)
{
	rootPane = new NavigationPane;

	initPageAccueil();
	initPageQuizz();

	pageQuestion = new Page();
	Container* questionContainer = new Container();
	questionContainer->setLayout(StackLayout::create());

	Label* question = new Label();
	question->setHorizontalAlignment(HorizontalAlignment::Center);
	question->setVerticalAlignment(VerticalAlignment::Center);
	question->setText("Ceci est une question");
	questionContainer->add(question);

	Button* reponse = new Button();
	reponse->setHorizontalAlignment(HorizontalAlignment::Center);
	reponse->setVerticalAlignment(VerticalAlignment::Bottom);
	reponse->setTopMargin(20.0f);
	reponse->setText("Réponse");
	questionContainer->add(reponse);

	pageQuestion->setContent(questionContainer);

	connect(commencer, SIGNAL(clicked()), this, SLOT(handleCommencerClicked()));
	connect(quizz, SIGNAL(clicked()), this, SLOT(handleQuizzClicked()));

	rootPane->push(pageAccueil);
	Application::instance()->setScene(rootPane);
}

void Quizz::initPageAccueil()
{
	Page* pageAccueil = new Page();
	Container* accueilContainer = new Container();
	accueilContainer->setLayout(StackLayout::create());

	Label* bienvenue = new Label();
	bienvenue->setMultiline(true);
	bienvenue->setHorizontalAlignment(HorizontalAlignment::Center);
	bienvenue->setVerticalAlignment(VerticalAlignment::Center);
	bienvenue->setText("Bienvenue \n sur \n Quizz");
	accueilContainer->add(bienvenue);

	Button* commencer = new Button();
	commencer->setHorizontalAlignment(HorizontalAlignment::Center);
	commencer->setVerticalAlignment(VerticalAlignment::Bottom);
	commencer->setTopMargin(20.0f);
	commencer->setText("Commencer");
	accueilContainer->add(commencer);

	pageAccueil->setContent(accueilContainer);
}

void Quizz::initPageQuizz()
{
	Page* pageQuizz = new Page();
	Container* quizzContainer = new Container();
	quizzContainer->setLayout(StackLayout::create());

	Label* choixQuizz = new Label();
	choixQuizz->setHorizontalAlignment(HorizontalAlignment::Center);
	choixQuizz->setVerticalAlignment(VerticalAlignment::Center);
	choixQuizz->setText("Choisissez votre Quizz");
	quizzContainer->add(choixQuizz);

	Button* quizz = new Button();
	quizz->setHorizontalAlignment(HorizontalAlignment::Center);
	quizz->setVerticalAlignment(VerticalAlignment::Bottom);
	quizz->setTopMargin(20.0f);
	quizz->setText("Quizz 1");
	quizzContainer->add(quizz);

	pageQuizz->setContent(quizzContainer);
}

void Quizz::handleCommencerClicked()
{
	rootPane->push(pageQuizz);
}

void Quizz::handleQuizzClicked()
{
	rootPane->push(pageQuestion);
}

 

Quizz.h

#ifndef Quizz_HPP_
#define Quizz_HPP_

#include <QObject>
#include <bb/cascades/Application>
#include <bb/cascades/QmlDocument>
#include <bb/cascades/AbstractPane>

#include <bb/cascades/NavigationPane>
#include <bb/cascades/Page>
#include <bb/cascades/Container>
#include <bb/cascades/StackLayout>
#include <bb/cascades/StackLayoutProperties>
#include <bb/cascades/DockLayout>
#include <bb/cascades/Label>
#include <bb/cascades/Button>

namespace bb { namespace cascades { class Application; }}

using namespace bb::cascades;

/*!
 * @brief Application pane object
 *
 *Use this object to create and init app UI, to create context objects, to register the new meta types etc.
 */
class Quizz : public QObject
{
    Q_OBJECT
public:
    Quizz(bb::cascades::Application *app);
    virtual ~Quizz() {}

public slots:
	void handleQuizzClicked();
	void handleCommencerClicked();

private:
    NavigationPane* rootPane;

    Page* pageAccueil;
    Container* accueilContainer;
    Label* bienvenue;
    Button* commencer;

    Page* pageQuizz;
    Container* quizzContainer;
    Label* choixQuizz;
    Button* quizz;

    Page* pageQuestion;

    void initPageAccueil();
    void initPageQuizz();
};


#endif /* Quizz_HPP_ */

 That's a long post :smileytongue: thanks in advance for your help and for reading me.

Please use plain text.
New Contributor
Vin_s
Posts: 5
Registered: ‎11-16-2012
My Device: BB10 DevAlpha

Re: BB10 Pages navigation issues

Well good news : I've just found the solution for the functions thing, but handling the second signal to push the third page when clicking on the second page's button is still a problem, so if anybody has an idea !

Please use plain text.
New Contributor
Vin_s
Posts: 5
Registered: ‎11-16-2012
My Device: BB10 DevAlpha

Re: BB10 Pages navigation issues

Annnnnnd it's gone, no more problem !

Please use plain text.
Super Contributor
pg1181
Posts: 398
Registered: ‎01-12-2011
My Device: Q10

Re: BB10 Pages navigation issues

How did you fix it??
Please use plain text.