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
Developer
Posts: 188
Registered: ‎07-19-2012
My Device: Z10 Limited Edition and Dev Alpha C
My Carrier: Movistar-Venezuela
Accepted Solution

Button Exit

Goodnight, you create an Exit button in my app with this code but I closed QML will enter it wrong? or there will be another code that can with a navigation button closing my app.

 

            ActionItem {
                title: "Exit"
                imageSource: "asset:///images/icons/exit.png"
                ActionBar.placement: ActionBarPlacement.OnBar
                onTriggered: {
                    _app.exitApp();
                   }

 

 


Follow me in Twitter:

@Marcossit

BBM Channel:

MarcossitDev: C0002C366  

DeviceSuite For BlackBerry 10:

Link to Download DeviceSuite:

Support was successful? Accept as Solution and click on:


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

Re: Button Exit

@marcossit

 

To implement the quit function in xml.

 

3 Files are automatically generated in the src folder with you create new Cascades Project 

  1. main.cpp
  2. [app].cpp
  3. [app].hpp

Open up [app.cpp]

 

Under 

locate the contstructor

using namespace bb::cascades;
App::App(bb::cascades::Application *app)
: QObject(app)
{

    // create scene document from main.qml asset
    // set parent to created document to ensure it exists for the whole application lifetime
    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);

    // create root object for the UI
    AbstractPane *root = qml->createRootObject<AbstractPane>();
    // set created root object as a scene
    app->setScene(root);
}

 

IMPORTANT 

(bb::cascades::Application *app)


If not already there make sure bb::cascades::Application *app is between the parenthesis.



How To Force Quit Application from QML

You will need to execute the quit() method.
Reference: https://developer.blackberry.com/cascades/reference/bb__cascades__application.html


main.qml

Application.quit();

 
And in your code specifically, this will work:

 

 ActionItem {
                title: "Exit"
                imageSource: "asset:///images/icons/exit.png"
                ActionBar.placement: ActionBarPlacement.OnBar
                onTriggered: {
                    Application.quit();
                   }

 
That's it. Best of luck to you in your development!

Please LIKE & ACCEPT AS SOLUTION



New Developer
Posts: 17
Registered: ‎05-09-2011
My Device: 9700
My Carrier: pelephone

Re: Button Exit

@greenback I dont have Application context when i try to use it in QML page (auto-complete also doesnt detect it) do u know why it is?

 

@marcossit i manage to do it by connecting the Qt.quit signal to the app quit slot in c++

 

just paste this code in your [project name class].cpp after qml pointer initialization

QObject

::connect(qml->documentContext()->engine(), SIGNAL(quit()), app, SLOT(quit()));

New Developer
Posts: 17
Registered: ‎05-09-2011
My Device: 9700
My Carrier: pelephone

Re: Button Exit

@greenback i think i just noticed your mistake... you forget to set the app as a context property...
qml->setContextProperty("Application", this); is missing from your code