class KMessageBox

Easy message dialog box. More...

Definition#include <kmessagebox.h>
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Types

Public Static Methods


Detailed Description

Easy message dialog box.

Provides convenience functions for some i18n'ed standard dialogs.

The text in message boxes is wrapped automatically. The text may either be plaintext or richtext. If the text is plaintext, a newline-character may be used to indicate the end of a paragraph.

enum ButtonCode { Ok = 1, Cancel = 2, Yes = 3, No = 4, Continue = 5 }

ButtonCode

Button types.

enum DialogType { QuestionYesNo = 1, WarningYesNo = 2, WarningContinueCancel = 3, WarningYesNoCancel = 4, Information = 5, Sorry = 7, Error = 8, QuestionYesNoCancel = 9 }

DialogType

enum OptionsType { Notify = 1, AllowLink = 2 }

OptionsType

int  questionYesNo (QWidget *parent, const QString &text, const QString &caption = QString::null, const KGuiItem &buttonYes = KStdGuiItem::yes(), const KGuiItem &buttonNo = KStdGuiItem::no(), const QString &dontAskAgainName = QString::null, int options = Notify)

questionYesNo

[static]

Display a simple "question" dialog.

To be used for questions like "Do you have a printer?"

The default button is "Yes". Pressing "Esc" selects "No".

Parameters:
parentIf parent is 0, then the message box becomes an application-global modal dialog box. If parent is a widget, the message box becomes modal relative to parent.
textMessage string.
captionMessage box title. The application name is added to the title. The default title is i18n("Question").
buttonYesThe text for the first button. The default is i18n("&Yes").
buttonNoThe text for the second button. The default is i18n("&No").
dontAskAgainNameIf provided, a checkbox is added with which further confirmation can be turned off. The string is used to lookup and store the setting in the applications config file.
options@see OptionsType

Returns: 'Yes' is returned if the Yes-button is pressed. 'No' is returned if the No-button is pressed.

int  questionYesNoCancel (QWidget *parent, const QString &text, const QString &caption = QString::null, const KGuiItem &buttonYes = KStdGuiItem::yes(), const KGuiItem &buttonNo = KStdGuiItem::no(), const QString &dontAskAgainName = QString::null, int options = Notify)

questionYesNoCancel

[static]

Display a simple "question" dialog.

To be used for questions like "Do you want to discard the message or save it for later?",

The default button is "Yes". Pressing "Esc" selects "Cancel".

NOTE: The cancel button will always have the i18n'ed text '&Cancel'.

Parameters:
parentIf parent is 0, then the message box becomes an application-global modal dialog box. If parent is a widget, the message box becomes modal relative to parent.
textMessage string.
captionMessage box title. The application name is added to the title. The default title is i18n("Question").
buttonYesThe text for the first button. The default is i18n("&Yes").
buttonNoThe text for the second button. The default is i18n("&No").
dontAskAgainNameIf provided, a checkbox is added with which further confirmation can be turned off. The string is used to lookup and store the setting in the applications config file.
options@see OptionsType

Returns: 'Yes' is returned if the Yes-button is pressed. 'No' is returned if the No-button is pressed.

int  questionYesNoList (QWidget *parent, const QString &text, const QStringList &strlist, const QString &caption = QString::null, const KGuiItem &buttonYes = KStdGuiItem::yes(), const KGuiItem &buttonNo = KStdGuiItem::no(), const QString &dontAskAgainName = QString::null, int options = Notify)

questionYesNoList

[static]

Display a "question" dialog with a listbox to show information to the user

To be used for questions like "Do you really want to delete these files?" And show the user exactly which files are going to be deleted in case he presses "Yes"

The default button is "Yes". Pressing "Esc" selects "No".

Parameters:
parentIf parent is 0, then the message box becomes an application-global modal dialog box. If parent is a widget, the message box becomes modal relative to parent.
textMessage string.
strlistList of strings to be written in the listbox. If the list is empty, it doesn't show any listbox, working as questionYesNo.
captionMessage box title. The application name is added to the title. The default title is i18n("Question").
buttonYesThe text for the first button. The default is i18n("&Yes").
buttonNoThe text for the second button. The default is i18n("&No").
dontAskAgainNameIf provided, a checkbox is added with which further confirmation can be turned off. The string is used to lookup and store the setting in the applications config file.
options@see OptionsType

Returns: 'Yes' is returned if the Yes-button is pressed. 'No' is returned if the No-button is pressed.

int  warningYesNo (QWidget *parent, const QString &text, const QString &caption = QString::null, const KGuiItem &buttonYes = KStdGuiItem::yes(), const KGuiItem &buttonNo = KStdGuiItem::no(), const QString &dontAskAgainName = QString::null, int options = Notify)

warningYesNo

[static]

Display a "warning" dialog.

To be used for questions "Shall I update your configuration?" The text should explain the implication of both options.

The default button is "No". Pressing "Esc" selects "No".

Parameters:
parentIf parent is 0, then the message box becomes an application-global modal dialog box. If parent is a widget, the message box becomes modal relative to parent.
textMessage string.
captionMessage box title. The application name is added to the title. The default title is i18n("Warning").
buttonYesThe text for the first button. The default is i18n("&Yes").
buttonNoThe text for the second button. The default is i18n("&No").
dontAskAgainNameIf provided, a checkbox is added with which further confirmation can be turned off. The string is used to lookup and store the setting in the applications config file.
options@see OptionsType

Returns: Yes is returned if the Yes-button is pressed. No is returned if the No-button is pressed.

int  warningContinueCancel (QWidget *parent, const QString &text, const QString &caption = QString::null, const KGuiItem &buttonContinue = KStdGuiItem::cont(), const QString &dontAskAgainName = QString::null, int options = Notify)

warningContinueCancel

[static]

Display a "warning" dialog.

The second button always has the text "Cancel".

To be used for questions like "You are about to Print. Are you sure?" the continueButton should then be labeled "Print".

The default button is buttonContinue. Pressing "Esc" selects "Cancel".

Parameters:
parentIf parent is 0, then the message box becomes an application-global modal dialog box. If parent is a widget, the message box becomes modal relative to parent.
textMessage string.
captionMessage box title. The application name is added to the title. The default title is i18n("Warning").
buttonContinueThe text for the first button.
dontAskAgainNameIf provided, a checkbox is added with which further confirmation can be turned off. The string is used to lookup and store the setting in the applications config file.
options@see OptionsType

Returns: Continue is returned if the Continue-button is pressed. Cancel is returned if the Cancel-button is pressed.

int  warningContinueCancelList (QWidget *parent, const QString &text, const QStringList &strlist, const QString &caption = QString::null, const KGuiItem &buttonContinue = QString::null, const QString &dontAskAgainName = QString::null, int options = Notify)

warningContinueCancelList

[static]

Display a "warning" dialog with a listbox to show information to the user.

The second button always has the text "Cancel".

To be used for questions like "You are about to Print. Are you sure?" the continueButton should then be labeled "Print".

The default button is buttonContinue. Pressing "Esc" selects "Cancel".

Parameters:
parentIf parent is 0, then the message box becomes an application-global modal dialog box. If parent is a widget, the message box becomes modal relative to parent.
textMessage string.
strlistList of strings to be written in the listbox. If the list is empty, it doesn't show any listbox, working as warningContinueCancel.
captionMessage box title. The application name is added to the title. The default title is i18n("Warning").
buttonContinueThe text for the first button.
dontAskAgainNameIf provided, a checkbox is added with which further confirmation can be turned off. The string is used to lookup and store the setting in the applications config file. The setting is stored in the "Notification Messages" group.
options@see OptionsType

Returns: Continue is returned if the Continue-button is pressed. Cancel is returned if the Cancel-button is pressed.

int  warningYesNoCancel (QWidget *parent, const QString &text, const QString &caption = QString::null, const KGuiItem &buttonYes = KStdGuiItem::yes(), const KGuiItem &buttonNo = KStdGuiItem::no(), const QString &dontAskAgainName = QString::null, int options = Notify)

warningYesNoCancel

[static]

Display a Yes/No/Cancel "warning" dialog.

To be used for questions "Do you want to save your changes?" The text should explain the implication of choosing 'No'.

The default button is "Yes". Pressing "Esc" selects "Cancel"

NOTE: The cancel button will always have the i18n'ed text '&Cancel'.

Parameters:
parentIf parent is 0, then the message box becomes an application-global modal dialog box. If parent is a widget, the message box becomes modal relative to parent.
textMessage string.
captionMessage box title. The application name is added to the title. The default title is i18n("Warning").
buttonYesThe text for the first button. The default is i18n("&Yes").
buttonNoThe text for the second button. The default is i18n("&No").
dontAskAgainNameIf provided, a checkbox is added with which further questions can be turned off. If turned off all questions will be automatically answered with the last answer (either Yes or No). The string is used to lookup and store the setting in the applications config file.
options@see OptionsType

Returns: Yes is returned if the Yes-button is pressed. No is returned if the No-button is pressed. Cancel is retunred if the Cancel- button is pressed.

void  error (QWidget *parent, const QString &text, const QString &caption = QString::null, int options = Notify)

error

[static]

Display an "Error" dialog.

Your program messed up and now it's time to inform the user. To be used for important things like "Sorry, I deleted your hard disk."

If your program detects the action specified by the user is somehow not allowed, this should never be reported with error(). Use sorry() instead to explain to the user that this action is not allowed.

The default button is "&OK". Pressing "Esc" selects the OK-button.

NOTE: The OK button will always have the i18n'ed text '&OK'.

Parameters:
parentIf parent is 0, then the message box becomes an application-global modal dialog box. If parent is a widget, the message box becomes modal relative to parent.
textMessage string.
captionMessage box title. The application name is added to the title. The default title is i18n("Error").
options@see OptionsType

void  detailedError (QWidget *parent, const QString &text, const QString &details, const QString &caption = QString::null, int options = Notify)

detailedError

[static]

Displays an "Error" dialog with a "Details >>" button.

Your program messed up and now it's time to inform the user. To be used for important things like "Sorry, I deleted your hard disk."

The details message can conatin additional information about the problem and can be shown on request to advanced/interested users.

If your program detects the action specified by the user is somehow not allowed, this should never be reported with error(). Use sorry() instead to explain to the user that this action is not allowed.

The default button is "&OK". Pressing "Esc" selects the OK-button.

NOTE: The OK button will always have the i18n'ed text '&OK'.

Parameters:
parentIf parent is 0, then the message box becomes an application-global modal dialog box. If parent is a widget, the message box becomes modal relative to parent.
textMessage string.
detailsDetailed message string.
captionMessage box title. The application name is added to the title. The default title is i18n("Error").
options@see OptionsType

void  queuedDetailedError ( QWidget *parent, const QString &text, const QString &details, const QString &caption = QString::null)

queuedDetailedError

[static]

Like detailedError

This function will return immediately, the messagebox will be shown once the application enters an event loop and no other messagebox is being shown.

Note that if the parent gets deleted, the messagebox will not be shown.

void  sorry (QWidget *parent, const QString &text, const QString &caption = QString::null, int options = Notify)

sorry

[static]

Display an "Sorry" dialog.

Either your program messed up and asks for understanding or your user did something stupid.

To be used for small problems like "Sorry, I can't find the file you specified."

The default button is "&OK". Pressing "Esc" selects the OK-button.

NOTE: The ok button will always have the i18n'ed text '&OK'.

Parameters:
parentIf parent is 0, then the message box becomes an application-global modal dialog box. If parent is a widget, the message box becomes modal relative to parent.
textMessage string.
captionMessage box title. The application name is added to the title. The default title is i18n("Sorry").
options@see OptionsType

void  detailedSorry (QWidget *parent, const QString &text, const QString &details, const QString &caption = QString::null, int options = Notify)

detailedSorry

[static]

Displays a "Sorry" dialog with a "Details >>" button.

Either your program messed up and asks for understanding or your user did something stupid.

To be used for small problems like "Sorry, I can't find the file you specified."

And then details can contain something like "foobar.txt was not found in any of the following directories: /usr/bin,/usr/local/bin,/usr/sbin"

The default button is "&OK". Pressing "Esc" selects the OK-button.

NOTE: The ok button will always have the i18n'ed text '&OK'.

Parameters:
parentIf parent is 0, then the message box becomes an application-global modal dialog box. If parent is a widget, the message box becomes modal relative to parent.
textMessage string.
detailsDetailed message string.
captionMessage box title. The application name is added to the title. The default title is i18n("Sorry").
options@see OptionsType

void  information (QWidget *parent, const QString &text, const QString &caption = QString::null, const QString &dontShowAgainName = QString::null, int options = Notify)

information

[static]

Display an "Information" dialog.

Your program wants to tell the user something. To be used for things like: "Your bookmarks have been rearranged."

The default button is "&OK". Pressing "Esc" selects the OK-button.

NOTE: The OK button will always have the i18n'ed text '&OK'.

Parameters:
parentIf parent is 0, then the message box becomes an application-global modal dialog box. If parent is a widget, the message box becomes modal relative to parent.
textMessage string.
captionMessage box title. The application name is added to the title. The default title is i18n("Information").
dontShowAgainNameIf provided, a checkbox is added with which further notifications can be turned off. The string is used to lookup and store the setting in the applications config file. The setting is stored in the "Notification Messages" group.
options@see OptionsType

void  enableAllMessages ()

enableAllMessages

[static]

Enable all messages which have been turned off with the dontShowAgainName feature of the information dialog.

void  about (QWidget *parent, const QString& text, const QString& caption = QString::null, int options = Notify)

about

[static]

Display an "About" dialog.

Your program wants to show some general information about the application like the authors's names and email addresses.

The default button is "&OK".

NOTE: The ok button will always have the i18n'ed text '&OK'.

Parameters:
parentIf parent is 0, then the message box becomes an application-global modal dialog box. If parent is a widget, the message box becomes modal relative to parent.
textMessage string.
captionMessage box title. The application name is added to the title. The default title is i18n("About ").
options@see OptionsType

int  messageBox ( QWidget *parent, DialogType type, const QString &text, const QString &caption = QString::null, const KGuiItem &buttonYes = KStdGuiItem::yes(), const KGuiItem &buttonNo = KStdGuiItem::no(), int options = Notify)

messageBox

[static]

Alternate method to show a messagebox:

Parameters:
parentIf parent is 0, then the message box becomes an application-global modal dialog box. If parent is a widget, the message box becomes modal relative to parent.
typetype of message box: QuestionYesNo, WarningYesNo, WarningContinueCancel...
textMessage string.
captionMessage box title.
buttonYesThe text for the first button. The default is i18n("&Yes").
buttonNoThe text for the second button. The default is i18n("&No").
options@see OptionsType Note: for ContinueCancel, buttonYes is the continue button and buttonNo is unused. and for Information, none is used.

Returns: a button code, as defined in KMessageBox, or 0 on communication error.

void  queuedMessageBox ( QWidget *parent, DialogType type, const QString &text, const QString &caption = QString::null )

queuedMessageBox

[static]