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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Highlighted
Developer
Posts: 614
Registered: ‎10-17-2010
My Device: (BlackBerry Z10)-> Q10/Passport Dual Use
Accepted Solution

Toast not declared in scope

Hello,

 

I am going through the updated docs and having issues implementing toasts.

 

void App::showToast() {
    toast = new SystemToast(this);
    toast->setBody("Welcome to the BlackBerry 10 Cascades documentation!" + "You have lots of space, but your text will wrap around in the dialog box.");
    toast->show();
}

 
returns an error: "toast not declared in scope" on this line:

toast = new SystemToast(this);

 
I added all these header files to my name .cpp

#include <bb/system/SystemDialog>
#include <bb/system/SystemListDialog>
#include <bb/system/SystemPrompt>
#include <bb/system/SystemCredentialsPrompt>
#include <bb/system/SystemToast>
#include <bb/system/SystemUiButton>
#include <bb/system/SystemUiInputField>
#include <bb/system/SystemUiError>
#include <bb/system/SystemUiInputMode>
#include <bb/system/SystemUiModality>
#include <bb/system/SystemUiPosition>
#include <bb/system/SystemUiResult>

using namespace bb::cascades;
using namespace bb::system;

 
my .pro includes these:

 

LIBS   += -lbbdata -lbbsystem


 my app.hpp header file looks like this

 

// List with context menu project template
#ifndef App_HPP_
#define App_HPP_

#include <QObject>

namespace bb { namespace cascades { class Application; }}

/*!
 * @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 App : public QObject
{
    Q_OBJECT
public:
    App(bb::cascades::Application *app);
    virtual ~App() {}
    void showToast();
};

#endif /* App_HPP_ */

 
Having a blast figuring out why its not working. Any of you have a working sample that connects everything to show a simple toast?


Thanks 

 

 

Regular Contributor
Posts: 76
Registered: ‎07-31-2012
My Device: Blackberry
My Carrier: Vodafone

Re: Toast not declared in scope

I guess you missed variable declaration.

 

Declare a SystemToast object either in method itself or in app.hpp like this:

 

SystemToast *toast;


Regards,

Nishant Shah

Developer
Posts: 614
Registered: ‎10-17-2010
My Device: (BlackBerry Z10)-> Q10/Passport Dual Use

Re: Toast not declared in scope

There was a typo in the docs.

Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Toast not declared in scope

Did you report the typo? Or at least just point out the error here...

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
Posts: 614
Registered: ‎10-17-2010
My Device: (BlackBerry Z10)-> Q10/Passport Dual Use

Re: Toast not declared in scope

Someone forgot to include 

SystemToast *

 

Developer
Posts: 79
Registered: ‎02-04-2013
My Device: Z10 LE
My Carrier: Simobil

Re: Toast not declared in scope

[ Edited ]

Hi guys,

I'm getting this error (invalid use of 'this' in non-member function). I have .hpp and .pro files same as above, and method looks like this:

void App::showToast() {
SystemToast *toast = new SystemToast(this);
toast->setBody("blablabla ");
toast->show();
}