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
Developer
Posts: 586
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

Highlighted
Developer
Posts: 586
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: 586
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();
}