libbb/Application_manualExit.cpp

This example illustrates how to connect to the Application manualExit signal in C++.
#include <bb/Application>
#include <QObject>

class TestObject: public QObject {
Q_OBJECT
public:
    TestObject(bb::Application *);
    virtual ~TestObject() {}
private Q_SLOTS:
    void onManualExit();
private:
    bb::Application * myapp;
};

TestObject::TestObject(bb::Application * app) : QObject(app) {
    myapp = app;
    // first connect the signal to the slot
    bool result = QObject::connect(myapp, SIGNAL(manualExit()), this, SLOT(onManualExit()));
    Q_ASSERT(result);
    Q_UNUSED(result);
    // then set autoExit to false
    myapp->setAutoExit(false);
    // make sure to set the the scene graph (Cascades) or otherwise start your application here.
    // In Cascades, not setting scene graph causes bb::cascades::Application not to be properly
    // initialized, and manualExit() won't get fired
}

void TestObject::onManualExit() {
    // Handle exit explicitly. Put your app specific code here.
    // Make sure to exit the application at the end.
    // Note that not calling quit will cause the app to hang, and in Debug mode the app won't
    // get slayed. It will be slayed after 3 seconds in Release mode.
    myapp->quit();
}

int main(int argc, char **argv) {
    bb::Application app(argc, argv);
    TestObject * testObject = new TextObject(&app);
    return app.exec();
}


Overview

Last modified: 2014-05-15



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus