Since: BlackBerry 10.0.0

#include <bb/ApplicationSupport>

To link against this class, add the following line to your .pro file: LIBS += -lbb

The ApplicationSupport class encapsulates functionality from the Application class for situations in which that class cannot be used.

The ApplicationSupport class can be used by any application that uses the QApplication class, which precludes the use of the Application class. These applications may still find it useful to have the following functionality available, so it is exposed in the ApplicationSupport class as well.


Public Functions Index

ApplicationSupport (QObject *parent=0)
virtual ~ApplicationSupport ()

Static Public Functions Index

boolclearClosePrompt ()
boolsetClosePrompt (const QString &title, const QString &message)

Public Functions

ApplicationSupport (

Create a new ApplicationSupport object.


If not 0, the supplied parent will be responsible for deleting this instance.


BlackBerry 10.0.0

virtual~ApplicationSupport ()



BlackBerry 10.0.0

Static Public Functions

bool clearClosePrompt ()

Clears the current close prompt.

This function removes any close prompt that was set, regardless of whether it was set using the setClosePrompt() method in the ApplicationSupport class or in the Application class. When the close prompt is cleared, no close prompt dialog box will appear when the user tries to close the application, and the application will exit normally.

If there is no current close prompt, this method has no effect.


true if the close prompt was cleared, false otherwise.


BlackBerry 10.0.0

bool setClosePrompt (

Sets a prompt to appear when the user attempts to close the application.

This function allows an application to prevent the user from closing the application without warning. If the user tries to close the application, a dialog box is displayed with the title and message specified. The dialog box will have 2 buttons: "Cancel" and "Close". If the user selects "Close", the application will be closed. If the user selects "Cancel", the dialog box will close and the application will continue running.

Note that the save prompt for an application is stored persistently on the device. The last call to this method or Application::setClosePrompt() determines the close prompt that will be shown. The close prompt persists until clearClosePrompt() is called on the ApplicationSupport class or on any Application object. Destroying the object that set the close prompt does not clear the prompt.

Note that all commas and double quotes are stripped from the title and message parameters before they are displayed. These characters cannot be displayed correctly. If the text also includes backslash characters ('\'), this process can introduce unexpected white space characters like tabs ('\t') and newlines ('\n'). Since these whitespace characters are allowed in the dialog box, they cannot be stripped.

Escape characters can be used, but they may be awkward to specify. The string provided to this method is in turn forwarded to the device's home screen process, which interprets the string a second time, including any escape characters. This can require multiple levels of escaping to produce the desired effect. For instance, to add a backslash ('\') character to the close prompt, the string "\\\\" must be used. This provides the string "\\" to this object. When this string is forwarded to the home screen, "\\" is interpreted again to become '\'.


The title of the close prompt dialog box. This title replaces the current close prompt title if it is already set.


The message of the close prompt dialog box. This message replaces the current close prompt message if it is already set.


true if the close prompt was set, false otherwise.


BlackBerry 10.0.0

Last modified: 2015-03-26

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

comments powered by Disqus