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
Accepted Solution

Creating a single screen tutorial - errors.

I'm doing the single screen tutorial here, using C++.

 

https://developer.blackberry.com/cascades/documentation/ui/navigation/single_screen.html

 

There is some information missing from the tutorial and some information in it is incorrect. Could someone tell me what's going wrong with my code, I already changed the last section from this:

 

// Set the content of the page and display it
root->setContent(root);
Application::setScene(root);
 
To:
 
// Set the content of the page and display it
root->setContent(topContainer);
Application::setScene(root);

 

I'm still getting errors though:

 

### PPS Thread: STARTED (10)
ERROR:: QNXPpsSubscriptionServer: QNXPpsSubscriptionServer::createObject: (13) Failed to create dir /pps/services/automation/framework

ERROR:: QNXPpsSubscriptionServer: QNXPpsSubscriptionServer::subscribe: Failed to open /pps/services/automation/framework/control?delta,notify=430:00000001

Object::connect: No such slot App::handleAction1() in ../src/app.cpp:32
ASSERT: "res" in file ../src/app.cpp, line 33

 My complete code below:

 

app.hpp

 

#ifndef APP_H
#define APP_H

#include <QObject>
#include <bb/cascades/Label>

using namespace bb::cascades;

/*!
 * @brief Application GUI object
 */
class App : public QObject
{
    Q_OBJECT
public:
    App();

    void handleAction1();
    void handleAction2();
    Label *mLabel;
};

#endif // ifndef APP_H

 app.cpp

 

#include "app.hpp"

#include <bb/cascades/Application>
#include <bb/cascades/AbstractPane>
#include <bb/cascades/Container>
#include <bb/cascades/Page>
#include <bb/cascades/Label>
#include <bb/cascades/Button>
#include <bb/cascades/Slider>
#include <bb/cascades/ActionItem>

using namespace bb::cascades;

App::App()
{
	// The variable myLabel is of type Label, and is declared in a header file so
	// that the slots can access it. The slot functions handleAction1() and
	// handleAction2() are also declared in the header file.

	Page* root = new Page;

	// Create the container and label
	Container* topContainer = new Container;
	mLabel = Label::create("Initial text");
	topContainer->add(mLabel);

	// Create actions for the screen, and connect the triggered() signal of each
	// action to slot functions. Make sure to test the return value to detect any
	// errors.
	ActionItem* action1 = ActionItem::create().title("Action 1");
	ActionItem* action2 = ActionItem::create().title("Action 2");
	bool res = QObject::connect(action1, SIGNAL(triggered()), this,SLOT(handleAction1()));
	Q_ASSERT(res);
	res = QObject::connect(action2, SIGNAL(triggered()), this,SLOT(handleAction2()));
	Q_ASSERT(res);

	// Indicate that the variable res isn't used in the rest of the app, to prevent
	// a compiler warning
	Q_UNUSED(res);

	// Add the actions to the page
	root->addAction(action1, ActionBarPlacement::OnBar);
	root->addAction(action2, ActionBarPlacement::OnBar);

	// Set the content of the page and display it
	root->setContent(topContainer);
	Application::setScene(root);
}

// The slot function for action 1
void App::handleAction1()
{
    mLabel->setText("Action 1 selected!");
}

// The slot function for action 2
void App::handleAction2()
{
    mLabel->setText("Action 2 selected!");
}

 Thanks for any help!

 

 

--------------------------------------------------------------------------------------------------
BlackBerry Apps: Instruments | ARTPAD | Piano | Drums | Xylophone
Developer
Posts: 526
Registered: ‎05-17-2009
My Device: 9900
My Carrier: ATT

Re: Creating a single screen tutorial - errors.

You need to mark the slots as slots so that the qt meta object system knows about them. Should look like this 

 

 Q_SLOT void handleAction1();
 Q_SLOT void handleAction2();

 

Like all of my posts
Retired
Posts: 138
Registered: ‎05-11-2012
My Device: Developer
My Carrier: Developer

Re: Creating a single screen tutorial - errors.

Did the above solution work for you?

 

Graham

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

Re: Creating a single screen tutorial - errors.

Yes, it worked, only just got around to testing it. Can I sugest you update the tutorials with this information?

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