kdeui Library API Documentation

KMessageBox Class Reference

Easy message dialog box. More...

#include <kmessagebox.h>

List of all members.

Public Types

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

enum  DialogType {
  QuestionYesNo = 1, WarningYesNo = 2, WarningContinueCancel = 3, WarningYesNoCancel = 4,
  Information = 5, Sorry = 7, Error = 8, QuestionYesNoCancel = 9
}
enum  OptionsType { Notify = 1, AllowLink = 2 }
 
  • Notify Emit a KNotifyClient event (Not yet implemented)
  • AllowLink The message may contain links.
More...


Static Public Member Functions

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)
 Display a simple "question" dialog.

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)
 Display a simple "question" dialog.

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)
 Display a "question" dialog with a listbox to show information to the user.

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)
 Display a "warning" dialog.

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)
 Display a "warning" dialog.

int warningContinueCancelList (QWidget *parent, const QString &text, const QStringList &strlist, const QString &caption=QString::null, const KGuiItem &buttonContinue=KStdGuiItem::cont(), const QString &dontAskAgainName=QString::null, int options=Notify)
 Display a "warning" dialog with a listbox to show information to the user.

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)
 Display a Yes/No/Cancel "warning" dialog.

void error (QWidget *parent, const QString &text, const QString &caption=QString::null, int options=Notify)
 Display an "Error" dialog.

void detailedError (QWidget *parent, const QString &text, const QString &details, const QString &caption=QString::null, int options=Notify)
 Displays an "Error" dialog with a "Details >>" button.

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

void sorry (QWidget *parent, const QString &text, const QString &caption=QString::null, int options=Notify)
 Display an "Sorry" dialog.

void detailedSorry (QWidget *parent, const QString &text, const QString &details, const QString &caption=QString::null, int options=Notify)
 Displays a "Sorry" dialog with a "Details >>" button.

void information (QWidget *parent, const QString &text, const QString &caption=QString::null, const QString &dontShowAgainName=QString::null, int options=Notify)
 Display an "Information" dialog.

void informationList (QWidget *parent, const QString &text, const QStringList &strlist, const QString &caption=QString::null, const QString &dontShowAgainName=QString::null, int options=Notify)
 Display an "Information" dialog with a listbox.

void enableAllMessages ()
 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)
 Display an "About" dialog.

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)
 Alternate method to show a messagebox:.

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


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.

Author:
Waldo Bastian (bastian@kde.org)
Version:
Id
kmessagebox.h,v 1.41 2002/10/09 20:44:27 kloecker Exp

Definition at line 42 of file kmessagebox.h.


Member Enumeration Documentation

enum KMessageBox::ButtonCode
 

Button types.

Definition at line 48 of file kmessagebox.h.

enum KMessageBox::OptionsType
 

  • Notify Emit a KNotifyClient event (Not yet implemented)
  • AllowLink The message may contain links.

Definition at line 74 of file kmessagebox.h.


Member Function Documentation

int KMessageBox::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
[static]
 

Display a simple "question" dialog.

Parameters:
parent If 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.
text Message string.
caption Message box title. The application name is added to the title. The default title is i18n("Question").
buttonYes The text for the first button. The default is i18n("&Yes").
buttonNo The text for the second button. The default is i18n("&No").
dontAskAgainName If 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.
To be used for questions like "Do you have a printer?"

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

Definition at line 216 of file kmessagebox.cpp.

References questionYesNoList().

Referenced by messageBox(), and KBugReport::slotOk().

int KMessageBox::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
[static]
 

Display a simple "question" dialog.

Parameters:
parent If 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.
text Message string.
caption Message box title. The application name is added to the title. The default title is i18n("Question").
buttonYes The text for the first button. The default is i18n("&Yes").
buttonNo The text for the second button. The default is i18n("&No").
dontAskAgainName If 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.
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'.

Definition at line 299 of file kmessagebox.cpp.

References KGlobal::config(), QString::fromLatin1(), QString::isEmpty(), QString::lower(), KConfigBase::readEntry(), KConfigBase::sync(), and KConfigBase::writeEntry().

Referenced by messageBox().

int KMessageBox::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
[static]
 

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

Parameters:
parent If 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.
text Message string.
strlist List of strings to be written in the listbox. If the list is empty, it doesn't show any listbox, working as questionYesNo.
caption Message box title. The application name is added to the title. The default title is i18n("Question").
buttonYes The text for the first button. The default is i18n("&Yes").
buttonNo The text for the second button. The default is i18n("&No").
dontAskAgainName If 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.
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".

Definition at line 229 of file kmessagebox.cpp.

References KGlobal::config(), QString::fromLatin1(), QString::isEmpty(), QString::lower(), KConfigBase::readEntry(), KConfigBase::sync(), and KConfigBase::writeEntry().

Referenced by questionYesNo().

int KMessageBox::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
[static]
 

Display a "warning" dialog.

Parameters:
parent If 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.
text Message string.
caption Message box title. The application name is added to the title. The default title is i18n("Warning").
buttonYes The text for the first button. The default is i18n("&Yes").
buttonNo The text for the second button. The default is i18n("&No").
dontAskAgainName If 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.
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".

Definition at line 374 of file kmessagebox.cpp.

References KGlobal::config(), QString::fromLatin1(), QString::isEmpty(), QString::lower(), KConfigBase::readEntry(), KConfigBase::sync(), and KConfigBase::writeEntry().

Referenced by messageBox(), and KBugReport::slotCancel().

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

Display a "warning" dialog.

Parameters:
parent If 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.
text Message string.
caption Message box title. The application name is added to the title. The default title is i18n("Warning").
buttonContinue The text for the first button.
dontAskAgainName If 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
The second button always has the text "Cancel".

Returns:
Continue is returned if the Continue-button is pressed. Cancel is returned if the Cancel-button is pressed.
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".

Definition at line 444 of file kmessagebox.cpp.

References warningContinueCancelList().

Referenced by messageBox().

int KMessageBox::warningContinueCancelList QWidget parent,
const QString text,
const QStringList strlist,
const QString caption = QString::null,
const KGuiItem &  buttonContinue = KStdGuiItem::cont(),
const QString dontAskAgainName = QString::null,
int  options = Notify
[static]
 

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

Parameters:
parent If 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.
text Message string.
strlist List of strings to be written in the listbox. If the list is empty, it doesn't show any listbox, working as warningContinueCancel.
caption Message box title. The application name is added to the title. The default title is i18n("Warning").
buttonContinue The text for the first button.
dontAskAgainName If 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
The second button always has the text "Cancel".

Returns:
Continue is returned if the Continue-button is pressed. Cancel is returned if the Cancel-button is pressed.
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".

Definition at line 456 of file kmessagebox.cpp.

References KGlobal::config(), QString::fromLatin1(), QString::isEmpty(), KConfigBase::readBoolEntry(), KConfigBase::sync(), and KConfigBase::writeEntry().

Referenced by warningContinueCancel().

int KMessageBox::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
[static]
 

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

Parameters:
parent If 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.
text Message string.
caption Message box title. The application name is added to the title. The default title is i18n("Warning").
buttonYes The text for the first button. The default is i18n("&Yes").
buttonNo The text for the second button. The default is i18n("&No").
dontAskAgainName If 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.
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'.

Definition at line 519 of file kmessagebox.cpp.

References KGlobal::config(), QString::fromLatin1(), QString::isEmpty(), QString::lower(), KConfigBase::readEntry(), KConfigBase::sync(), and KConfigBase::writeEntry().

Referenced by messageBox().

void KMessageBox::error QWidget parent,
const QString text,
const QString caption = QString::null,
int  options = Notify
[static]
 

Display an "Error" dialog.

Parameters:
parent If 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.
text Message string.
caption Message box title. The application name is added to the title. The default title is i18n("Error").
options see OptionsType
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'.

Definition at line 592 of file kmessagebox.cpp.

References QString::isEmpty().

Referenced by messageBox(), and KBugReport::slotOk().

void KMessageBox::detailedError QWidget parent,
const QString text,
const QString details,
const QString caption = QString::null,
int  options = Notify
[static]
 

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

Parameters:
parent If 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.
text Message string.
details Detailed message string.
caption Message box title. The application name is added to the title. The default title is i18n("Error").
options see OptionsType
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'.

Definition at line 606 of file kmessagebox.cpp.

References QString::isEmpty().

Referenced by queuedDetailedError().

void KMessageBox::queuedDetailedError QWidget parent,
const QString text,
const QString details,
const QString caption = QString::null
[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.

Definition at line 621 of file kmessagebox.cpp.

References detailedError().

void KMessageBox::sorry QWidget parent,
const QString text,
const QString caption = QString::null,
int  options = Notify
[static]
 

Display an "Sorry" dialog.

Parameters:
parent If 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.
text Message string.
caption Message box title. The application name is added to the title. The default title is i18n("Sorry").
options see OptionsType
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'.

Definition at line 632 of file kmessagebox.cpp.

References QString::isEmpty().

Referenced by messageBox(), and KPasswordDialog::slotOk().

void KMessageBox::detailedSorry QWidget parent,
const QString text,
const QString details,
const QString caption = QString::null,
int  options = Notify
[static]
 

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

Parameters:
parent If 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.
text Message string.
details Detailed message string.
caption Message box title. The application name is added to the title. The default title is i18n("Sorry").
options see OptionsType
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'.

Definition at line 646 of file kmessagebox.cpp.

References QString::isEmpty().

void KMessageBox::information QWidget parent,
const QString text,
const QString caption = QString::null,
const QString dontShowAgainName = QString::null,
int  options = Notify
[static]
 

Display an "Information" dialog.

Parameters:
parent If 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.
text Message string.
caption Message box title. The application name is added to the title. The default title is i18n("Information").
dontShowAgainName If 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
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'.

Definition at line 661 of file kmessagebox.cpp.

References informationList().

Referenced by messageBox(), and KBugReport::slotOk().

void KMessageBox::informationList QWidget parent,
const QString text,
const QStringList strlist,
const QString caption = QString::null,
const QString dontShowAgainName = QString::null,
int  options = Notify
[static]
 

Display an "Information" dialog with a listbox.

Parameters:
parent If 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.
text Message string.
strlist List of strings to be written in the listbox. If the list is empty, it doesn't show any listbox, working as information.
caption Message box title. The application name is added to the title. The default title is i18n("Information").
dontShowAgainName If 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
Your program wants to tell the user something. To be used for things like: "The following 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'.

Since:
3.1

Definition at line 668 of file kmessagebox.cpp.

References KGlobal::config(), QString::fromLatin1(), QString::isEmpty(), KConfigBase::readBoolEntry(), KConfigBase::sync(), and KConfigBase::writeEntry().

Referenced by information().

void KMessageBox::enableAllMessages  )  [static]
 

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

Definition at line 714 of file kmessagebox.cpp.

References KGlobal::config(), KConfig::entryMap(), QString::fromLatin1(), KConfigBase::hasGroup(), KConfigBase::sync(), and KConfigBase::writeEntry().

void KMessageBox::about QWidget parent,
const QString text,
const QString caption = QString::null,
int  options = Notify
[static]
 

Display an "About" dialog.

Parameters:
parent If 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.
text Message string.
caption Message box title. The application name is added to the title. The default title is i18n("About <appname>").
options see OptionsType
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'.

Definition at line 734 of file kmessagebox.cpp.

References QMessageBox::adjustSize(), QString::arg(), QString::isEmpty(), QMessageBox::setButtonText(), and QMessageBox::setIconPixmap().

int KMessageBox::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
[static]
 

Alternate method to show a messagebox:.

Parameters:
parent If 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.
type type of message box: QuestionYesNo, WarningYesNo, WarningContinueCancel...
text Message string.
caption Message box title.
buttonYes The text for the first button. The default is i18n("&Yes").
buttonNo The 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.

Definition at line 757 of file kmessagebox.cpp.

References error(), information(), questionYesNo(), questionYesNoCancel(), sorry(), warningContinueCancel(), warningYesNo(), and warningYesNoCancel().

Referenced by queuedMessageBox().

void KMessageBox::queuedMessageBox QWidget parent,
DialogType  type,
const QString text,
const QString caption = QString::null
[static]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Definition at line 799 of file kmessagebox.cpp.

References messageBox().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sun Feb 27 22:15:09 2005 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001