Pregunta

In my App, when ever BB 10 Device is in Offline... I need to show a dialog box with "Ok" Button.pressing "Ok" button Should Terminate the APP !!!

 SystemDialog *dialog;
dialog = new SystemDialog(tr("OK"), 0);
dialog->setTitle(tr("Alert")); 
dialog->setBody(message); 
dialog->setDismissAutomatically(true);.
connect(dialog, SIGNAL(finished(bb::system::SystemUiResult::Type)), dialog,
        SLOT(deleteLater()));
dialog->show();

Here deleteLater() is SystemSlot which is only terminating the Alert Dialog box but not the App!!! How to Do this in BB 10 Cascades through C++ Code? IS it possible to Override deleteLater() SystemSlot like this,

// I replaced deleteLater() with SLOT(deleteLaters()) in above code and Added this Slot
 void deleteLaters(){
  bb::Application::exit(0);
  }

Then Its is Saying, No such slot deleteLaters() Found in bb::System !!!

Please Help,

Thankks!!!

¿Fue útil?

Solución

I guess you are just trying to connect the SystemDialog finished signal to a the same object's deleteLaters slot (which doesn't exist).

Try something like the next code, where myObject might just be this if you declare your slot in your class.

int connectResult = connect(dialog, 
                            SIGNAL(finished(bb::system::SystemUiResult::Type)),
                            myObject, 
                            SLOT(deleteLaters()));
Q_ASSERT(connectResult);
Q_RESULT(connectResult);

For more information on how to properly declare your new slot in your class, see the signals and slots documentation.

Note: If you really need to close the application (which is not recommended), I believe you should use Application::instance->requestExit() to do it properly. If you don't need to do anything else before closing the application, you might directly connect the signal to the requestExit() slot:

int connectResult = connect(dialog, 
                            SIGNAL(finished(bb::system::SystemUiResult::Type)),
                            Application::instance, 
                            SLOT(requestExit()));
Q_ASSERT(connectResult);
Q_RESULT(connectResult);
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top