Eneboo - Documentación para desarrolladores
Tipos públicos | Métodos públicos | Métodos públicos estáticos | Métodos protegidos | Propiedades
Referencia de la Clase QMessageBox

The QMessageBox class provides a modal dialog with a short message, an icon, and some buttons.. Más...

#include <qmessagebox.h>

Diagrama de herencias de QMessageBox
QDialog QDialog QWidget QWidget QWidget QWidget QPaintDevice QObject QPaintDevice QObject QPaintDevice QObject QPaintDevice QObject QPaintDevice QObject QPaintDevice QObject QPaintDevice QObject QPaintDevice QObject

Lista de todos los miembros.

Tipos públicos

enum  Icon {
  NoIcon = 0, Information = 1, Warning = 2, Critical = 3,
  Question = 4, NoIcon = 0, Information = 1, Warning = 2,
  Critical = 3, Question = 4
}
enum  {
  NoButton = 0, Ok = 1, Cancel = 2, Yes = 3,
  No = 4, Abort = 5, Retry = 6, Ignore = 7,
  YesAll = 8, NoAll = 9, ButtonMask = 0xff, Default = 0x100,
  Escape = 0x200, FlagMask = 0x300
}
enum  Icon {
  NoIcon = 0, Information = 1, Warning = 2, Critical = 3,
  Question = 4, NoIcon = 0, Information = 1, Warning = 2,
  Critical = 3, Question = 4
}
enum  {
  NoButton = 0, Ok = 1, Cancel = 2, Yes = 3,
  No = 4, Abort = 5, Retry = 6, Ignore = 7,
  YesAll = 8, NoAll = 9, ButtonMask = 0xff, Default = 0x100,
  Escape = 0x200, FlagMask = 0x300
}

Métodos públicos

 QMessageBox (QWidget *parent=0, const char *name=0)
 QMessageBox (const QString &caption, const QString &text, Icon icon, int button0, int button1, int button2, QWidget *parent=0, const char *name=0, bool modal=TRUE, WFlags f=WStyle_DialogBorder)
 ~QMessageBox ()
QString text () const
void setText (const QString &)
Icon icon () const
void setIcon (Icon)
void setIcon (const QPixmap &)
const QPixmapiconPixmap () const
void setIconPixmap (const QPixmap &)
QString buttonText (int button) const
void setButtonText (int button, const QString &)
void adjustSize ()
TextFormat textFormat () const
void setTextFormat (TextFormat)
 QMessageBox (QWidget *parent=0, const char *name=0)
 QMessageBox (const QString &caption, const QString &text, Icon icon, int button0, int button1, int button2, QWidget *parent=0, const char *name=0, bool modal=TRUE, WFlags f=WStyle_DialogBorder)
 ~QMessageBox ()
QString text () const
void setText (const QString &)
Icon icon () const
void setIcon (Icon)
void setIcon (const QPixmap &)
const QPixmapiconPixmap () const
void setIconPixmap (const QPixmap &)
QString buttonText (int button) const
void setButtonText (int button, const QString &)
void adjustSize ()
TextFormat textFormat () const
void setTextFormat (TextFormat)

Métodos públicos estáticos

static int information (QWidget *parent, const QString &caption, const QString &text, int button0, int button1=0, int button2=0)
static int information (QWidget *parent, const QString &caption, const QString &text, const QString &button0Text=QString::null, const QString &button1Text=QString::null, const QString &button2Text=QString::null, int defaultButtonNumber=0, int escapeButtonNumber=-1)
static int question (QWidget *parent, const QString &caption, const QString &text, int button0, int button1=0, int button2=0)
static int question (QWidget *parent, const QString &caption, const QString &text, const QString &button0Text=QString::null, const QString &button1Text=QString::null, const QString &button2Text=QString::null, int defaultButtonNumber=0, int escapeButtonNumber=-1)
static int warning (QWidget *parent, const QString &caption, const QString &text, int button0, int button1, int button2=0)
static int warning (QWidget *parent, const QString &caption, const QString &text, const QString &button0Text=QString::null, const QString &button1Text=QString::null, const QString &button2Text=QString::null, int defaultButtonNumber=0, int escapeButtonNumber=-1)
static int critical (QWidget *parent, const QString &caption, const QString &text, int button0, int button1, int button2=0)
static int critical (QWidget *parent, const QString &caption, const QString &text, const QString &button0Text=QString::null, const QString &button1Text=QString::null, const QString &button2Text=QString::null, int defaultButtonNumber=0, int escapeButtonNumber=-1)
static void about (QWidget *parent, const QString &caption, const QString &text)
static void aboutQt (QWidget *parent, const QString &caption=QString::null)
static int message (const QString &caption, const QString &text, const QString &buttonText=QString::null, QWidget *parent=0, const char *=0)
static bool query (const QString &caption, const QString &text, const QString &yesButtonText=QString::null, const QString &noButtonText=QString::null, QWidget *parent=0, const char *=0)
static QPixmap standardIcon (Icon icon, GUIStyle)
static QPixmap standardIcon (Icon icon)
static int information (QWidget *parent, const QString &caption, const QString &text, int button0, int button1=0, int button2=0)
static int information (QWidget *parent, const QString &caption, const QString &text, const QString &button0Text=QString::null, const QString &button1Text=QString::null, const QString &button2Text=QString::null, int defaultButtonNumber=0, int escapeButtonNumber=-1)
static int question (QWidget *parent, const QString &caption, const QString &text, int button0, int button1=0, int button2=0)
static int question (QWidget *parent, const QString &caption, const QString &text, const QString &button0Text=QString::null, const QString &button1Text=QString::null, const QString &button2Text=QString::null, int defaultButtonNumber=0, int escapeButtonNumber=-1)
static int warning (QWidget *parent, const QString &caption, const QString &text, int button0, int button1, int button2=0)
static int warning (QWidget *parent, const QString &caption, const QString &text, const QString &button0Text=QString::null, const QString &button1Text=QString::null, const QString &button2Text=QString::null, int defaultButtonNumber=0, int escapeButtonNumber=-1)
static int critical (QWidget *parent, const QString &caption, const QString &text, int button0, int button1, int button2=0)
static int critical (QWidget *parent, const QString &caption, const QString &text, const QString &button0Text=QString::null, const QString &button1Text=QString::null, const QString &button2Text=QString::null, int defaultButtonNumber=0, int escapeButtonNumber=-1)
static void about (QWidget *parent, const QString &caption, const QString &text)
static void aboutQt (QWidget *parent, const QString &caption=QString::null)
static int message (const QString &caption, const QString &text, const QString &buttonText=QString::null, QWidget *parent=0, const char *=0)
static bool query (const QString &caption, const QString &text, const QString &yesButtonText=QString::null, const QString &noButtonText=QString::null, QWidget *parent=0, const char *=0)
static QPixmap standardIcon (Icon icon, GUIStyle)
static QPixmap standardIcon (Icon icon)

Métodos protegidos

void resizeEvent (QResizeEvent *)
void showEvent (QShowEvent *)
void closeEvent (QCloseEvent *)
void keyPressEvent (QKeyEvent *)
void styleChanged (QStyle &)
void resizeEvent (QResizeEvent *)
void showEvent (QShowEvent *)
void closeEvent (QCloseEvent *)
void keyPressEvent (QKeyEvent *)
void styleChanged (QStyle &)

Propiedades

QString text
 the message box text to be displayed.
Icon icon
 the message box's icon
QPixmap iconPixmap
 the current icon
TextFormat textFormat
 the format of the text displayed by the message box

Descripción detallada

The QMessageBox class provides a modal dialog with a short message, an icon, and some buttons.

.

Message boxes are used to provide informative messages and to ask simple questions.

QMessageBox provides a range of different messages, arranged roughly along two axes: severity and complexity.

Severity is qmessagebox-quest.png Question For message boxes that ask a question as part of normal operation. Some style guides recommend using Information for this purpose. qmessagebox-info.png Information For message boxes that are part of normal operation. qmessagebox-warn.png Warning For message boxes that tell the user about unusual errors. qmessagebox-crit.png Critical For message boxes that tell the user about critical errors.

The message box has a different icon for each of the severity levels.

Complexity is one button (OK) for simple messages, or two or even three buttons for questions.

There are static functions for the most common cases.

Examples:

If a program is unable to find a supporting file, but can do perfectly well without it:

    QMessageBox::information( this, "Application name",
    "Unable to find the user preferences file.\n"
    "The factory default will be used instead." );

question() is useful for simple yes/no questions:

    if ( QFile::exists( filename ) &&
        QMessageBox::question(
            this,
            tr("Overwrite File? -- Application Name"),
            tr("A file called %1 already exists."
                "Do you want to overwrite it?")
                .arg( filename ),
            tr("&Yes"), tr("&No"),
            QString::null, 0, 1 ) )
        return false;

warning() can be used to tell the user about unusual errors, or errors which can't be easily fixed:

    switch( QMessageBox::warning( this, "Application name",
        "Could not connect to the <mumble> server.\n"
        "This program can't function correctly "
        "without the server.\n\n",
        "Retry",
        "Quit", 0, 0, 1 ) ) {
    case 0: // The user clicked the Retry again button or pressed Enter
        // try again
        break;
    case 1: // The user clicked the Quit or pressed Escape
        // exit
        break;
    }

The text part of all message box messages can be either rich text or plain text. If you specify a rich text formatted string, it will be rendered using the default stylesheet. See QStyleSheet::defaultSheet() for details. With certain strings that contain XML meta characters, the auto-rich text detection may fail, interpreting plain text incorrectly as rich text. In these rare cases, use QStyleSheet::convertFromPlainText() to convert your plain text string to a visually equivalent rich text string or set the text format explicitly with setTextFormat().

Note that the Microsoft Windows User Interface Guidelines recommend using the application name as the window's caption.

Below are more examples of how to use the static member functions. After these examples you will find an overview of the non-static member functions.

Exiting a program is part of its normal operation. If there is unsaved data the user probably should be asked if they want to save the data. For example:

    switch( QMessageBox::information( this, "Application name here",
        "The document contains unsaved changes\n"
        "Do you want to save the changes before exiting?",
        "&Save", "&Discard", "Cancel",
        0,      // Enter == button 0
        2 ) ) { // Escape == button 2
    case 0: // Save clicked or Alt+S pressed or Enter pressed.
        // save
        break;
    case 1: // Discard clicked or Alt+D pressed
        // don't save but exit
        break;
    case 2: // Cancel clicked or Escape pressed
        // don't exit
        break;
    }

The Escape button cancels the entire exit operation, and pressing Enter causes the changes to be saved before the exit occurs.

Disk full errors are unusual and they certainly can be hard to correct. This example uses predefined buttons instead of hard-coded button texts:

    switch( QMessageBox::warning( this, "Application name here",
        "Could not save the user preferences,\n"
        "because the disk is full. You can delete\n"
        "some files and press Retry, or you can\n"
        "abort the Save Preferences operation.",
        QMessageBox::Retry | QMessageBox::Default,
        QMessageBox::Abort | QMessageBox::Escape )) {
    case QMessageBox::Retry: // Retry clicked or Enter pressed
        // try again
        break;
    case QMessageBox::Abort: // Abort clicked or Escape pressed
        // abort
        break;
    }

The critical() function should be reserved for critical errors. In this example errorDetails is a QString or const char*, and QString is used to concatenate several strings:

    QMessageBox::critical( 0, "Application name here",
        QString("An internal error occurred. Please ") +
        "call technical support at 1234-56789 and report\n"+
        "these numbers:\n\n" + errorDetails +
        "\n\nApplication will now exit." );

In this example an OK button is displayed.

QMessageBox provides a very simple About box which displays an appropriate icon and the string you provide:

    QMessageBox::about( this, "About <Application>",
        "<Application> is a <one-paragraph blurb>\n\n"
        "Copyright 1991-2003 Such-and-such. "
        "<License words here.>\n\n"
        "For technical support, call 1234-56789 or see\n"
        "http://www.such-and-such.com/Application/\n" );

See about() for more information.

If you want your users to know that the application is built using Qt (so they know that you use high quality tools) you might like to add an "About Qt" menu option under the Help menu to invoke aboutQt().

If none of the standard message boxes is suitable, you can create a QMessageBox from scratch and use custom button texts:

    QMessageBox mb( "Application name here",
        "Saving the file will overwrite the original file on the disk.\n"
        "Do you really want to save?",
        QMessageBox::Information,
        QMessageBox::Yes | QMessageBox::Default,
        QMessageBox::No,
        QMessageBox::Cancel | QMessageBox::Escape );
    mb.setButtonText( QMessageBox::Yes, "Save" );
    mb.setButtonText( QMessageBox::No, "Discard" );
    switch( mb.exec() ) {
    case QMessageBox::Yes:
        // save and exit
        break;
    case QMessageBox::No:
        // exit without saving
        break;
    case QMessageBox::Cancel:
        // don't save and don't exit
        break;
    }

QMessageBox defines two enum types: Icon and an unnamed button type. Icon defines the Question, Information, Warning, and Critical icons for each GUI style. It is used by the constructor and by the static member functions question(), information(), warning() and critical(). A function called standardIcon() gives you access to the various icons.

The button types are: Ok - the default for single-button message boxes Cancel - note that this is not automatically Escape Yes No Abort Retry Ignore YesAll NoAll

Button types can be combined with two modifiers by using OR, '|': Default - makes pressing Enter equivalent to clicking this button. Normally used with Ok, Yes or similar. Escape - makes pressing Escape equivalent to clicking this button. Normally used with Abort, Cancel or similar.

The text(), icon() and iconPixmap() functions provide access to the current text and pixmap of the message box. The setText(), setIcon() and setIconPixmap() let you change it. The difference between setIcon() and setIconPixmap() is that the former accepts a QMessageBox::Icon and can be used to set standard icons, whereas the latter accepts a QPixmap and can be used to set custom icons.

setButtonText() and buttonText() provide access to the buttons.

QMessageBox has no signals or slots.

qmsgbox-m.png
qmsgbox-w.png
Ver también:
QDialog, Isys on error messages , GUI Design Handbook: Message Box

Documentación de las enumeraciones miembro de la clase

anonymous enum
Valores de enumeraciones:
NoButton 
Ok 
Cancel 
Yes 
No 
Abort 
Retry 
Ignore 
YesAll 
NoAll 
ButtonMask 
Default 
Escape 
FlagMask 
anonymous enum
Valores de enumeraciones:
NoButton 
Ok 
Cancel 
Yes 
No 
Abort 
Retry 
Ignore 
YesAll 
NoAll 
ButtonMask 
Default 
Escape 
FlagMask 
Valores de enumeraciones:
NoIcon 
Information 
Warning 
Critical 
Question 
NoIcon 
Information 
Warning 
Critical 
Question 

This enum has the following values:

NoIcon the message box does not have any icon.

Question an icon indicating that the message is asking a question.

Information an icon indicating that the message is nothing out of the ordinary.

Warning an icon indicating that the message is a warning, but can be dealt with.

Critical an icon indicating that the message represents a critical problem.

Valores de enumeraciones:
NoIcon 
Information 
Warning 
Critical 
Question 
NoIcon 
Information 
Warning 
Critical 
Question 

Documentación del constructor y destructor

QMessageBox::QMessageBox ( QWidget parent = 0,
const char *  name = 0 
)

Constructs a message box with no text and a button with the label "OK".

If parent is 0, the message box becomes an application-global modal dialog box. If parent is a widget, the message box becomes modal relative to parent.

The parent and name arguments are passed to the QDialog constructor.

QMessageBox::QMessageBox ( const QString caption,
const QString text,
Icon  icon,
int  button0,
int  button1,
int  button2,
QWidget parent = 0,
const char *  name = 0,
bool  modal = TRUE,
WFlags  f = WStyle_DialogBorder 
)

Constructs a message box with a caption, a text, an icon, and up to three buttons.

The icon must be one of the following: QMessageBox::NoIcon QMessageBox::Question QMessageBox::Information QMessageBox::Warning QMessageBox::Critical

Each button, button0, button1 and button2, can have one of the following values: QMessageBox::NoButton QMessageBox::Ok QMessageBox::Cancel QMessageBox::Yes QMessageBox::No QMessageBox::Abort QMessageBox::Retry QMessageBox::Ignore QMessageBox::YesAll QMessageBox::NoAll

Use QMessageBox::NoButton for the later parameters to have fewer than three buttons in your message box. If you don't specify any buttons at all, QMessageBox will provide an Ok button.

One of the buttons can be OR-ed with the QMessageBox::Default flag to make it the default button (clicked when Enter is pressed).

One of the buttons can be OR-ed with the QMessageBox::Escape flag to make it the cancel or close button (clicked when Escape is pressed).

Example:

    QMessageBox mb( "Application Name",
        "Hardware failure.\n\nDisk error detected\nDo you want to stop?",
        QMessageBox::Question,
        QMessageBox::Yes | QMessageBox::Default,
        QMessageBox::No  | QMessageBox::Escape,
        QMessageBox::NoButton );
    if ( mb.exec() == QMessageBox::No )
        // try again

If parent is 0, the message box becomes an application-global modal dialog box. If parent is a widget, the message box becomes modal relative to parent.

If modal is TRUE the message box is modal; otherwise it is modeless.

The parent, name, modal, and f arguments are passed to the QDialog constructor.

Ver también:
setCaption(), setText(), setIcon()
QMessageBox::~QMessageBox ( )

Destroys the message box.

QMessageBox::QMessageBox ( QWidget parent = 0,
const char *  name = 0 
)
QMessageBox::QMessageBox ( const QString caption,
const QString text,
Icon  icon,
int  button0,
int  button1,
int  button2,
QWidget parent = 0,
const char *  name = 0,
bool  modal = TRUE,
WFlags  f = WStyle_DialogBorder 
)
QMessageBox::~QMessageBox ( )

Documentación de las funciones miembro

void QMessageBox::about ( QWidget parent,
const QString caption,
const QString text 
) [static]

Displays a simple about box with caption caption and text text. The about box's parent is parent.

about() looks for a suitable icon in four locations: 1 It prefers parent->icon() if that exists. If not, it tries the top-level widget containing parent. If that fails, it tries the main widget. As a last resort it uses the Information icon.

The about box has a single button labelled "OK".

Ver también:
QWidget::icon() QApplication::mainWidget()
static void QMessageBox::about ( QWidget parent,
const QString caption,
const QString text 
) [static]
void QMessageBox::aboutQt ( QWidget parent,
const QString caption = QString::null 
) [static]

Displays a simple message box about Qt, with caption caption and centered over parent (if parent is not 0). The message includes the version number of Qt being used by the application.

This is useful for inclusion in the Help menu of an application. See the examples/menu/menu.cpp example.

QApplication provides this functionality as a slot.

Ver también:
QApplication::aboutQt()
static void QMessageBox::aboutQt ( QWidget parent,
const QString caption = QString::null 
) [static]
void QMessageBox::adjustSize ( ) [virtual]

Adjusts the size of the message box to fit the contents just before QDialog::exec() or QDialog::show() is called.

This function will not be called if the message box has been explicitly resized before showing it.

Reimplementado de QWidget.

void QMessageBox::adjustSize ( ) [virtual]

Adjusts the size of the widget to fit the contents.

Uses sizeHint() if valid (i.e if the size hint's width and height are >= 0), otherwise sets the size to the children rectangle (the union of all child widget geometries).

Ver también:
sizeHint(), childrenRect()

Reimplementado de QWidget.

QString QMessageBox::buttonText ( int  button) const

Returns the text of the message box button button, or QString::null if the message box does not contain the button.

Ver también:
setButtonText()
QString QMessageBox::buttonText ( int  button) const
void QMessageBox::closeEvent ( QCloseEvent e) [protected, virtual]

Reimplementado de QDialog.

void QMessageBox::closeEvent ( QCloseEvent e) [protected, virtual]

Reimplementado de QDialog.

int QMessageBox::critical ( QWidget parent,
const QString caption,
const QString text,
const QString button0Text = QString::null,
const QString button1Text = QString::null,
const QString button2Text = QString::null,
int  defaultButtonNumber = 0,
int  escapeButtonNumber = -1 
) [static]

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Displays a critical error message box with a caption, a text, and 1, 2 or 3 buttons. Returns the number of the button that was clicked (0, 1 or 2).

button0Text is the text of the first button, and is optional. If button0Text is not supplied, "OK" (translated) will be used. button1Text is the text of the second button, and is optional, and button2Text is the text of the third button, and is optional. defaultButtonNumber (0, 1 or 2) is the index of the default button; pressing Return or Enter is the same as clicking the default button. It defaults to 0 (the first button). escapeButtonNumber is the index of the Escape button; pressing Escape is the same as clicking this button. It defaults to -1; supply 0, 1, or 2 to make pressing Escape equivalent to clicking the relevant button.

If parent is 0, the message box becomes an application-global modal dialog box. If parent is a widget, the message box becomes modal relative to parent.

Ver también:
information(), question(), warning()
static int QMessageBox::critical ( QWidget parent,
const QString caption,
const QString text,
int  button0,
int  button1,
int  button2 = 0 
) [static]
static int QMessageBox::critical ( QWidget parent,
const QString caption,
const QString text,
const QString button0Text = QString::null,
const QString button1Text = QString::null,
const QString button2Text = QString::null,
int  defaultButtonNumber = 0,
int  escapeButtonNumber = -1 
) [static]
int QMessageBox::critical ( QWidget parent,
const QString caption,
const QString text,
int  button0,
int  button1,
int  button2 = 0 
) [static]

Opens a critical message box with the caption caption and the text text. The dialog may have up to three buttons. Each of the button parameters, button0, button1 and button2 may be set to one of the following values:

QMessageBox::NoButton QMessageBox::Ok QMessageBox::Cancel QMessageBox::Yes QMessageBox::No QMessageBox::Abort QMessageBox::Retry QMessageBox::Ignore QMessageBox::YesAll QMessageBox::NoAll

If you don't want all three buttons, set the last button, or last two buttons to QMessageBox::NoButton.

One button can be OR-ed with QMessageBox::Default, and one button can be OR-ed with QMessageBox::Escape.

Returns the identity (QMessageBox::Ok, or QMessageBox::No, etc.) of the button that was clicked.

If parent is 0, the message box becomes an application-global modal dialog box. If parent is a widget, the message box becomes modal relative to parent.

Ver también:
information(), question(), warning()
Icon QMessageBox::icon ( ) const

Reimplementado de QWidget.

Icon QMessageBox::icon ( ) const

Reimplementado de QWidget.

const QPixmap* QMessageBox::iconPixmap ( ) const
const QPixmap* QMessageBox::iconPixmap ( ) const
static int QMessageBox::information ( QWidget parent,
const QString caption,
const QString text,
int  button0,
int  button1 = 0,
int  button2 = 0 
) [static]
static int QMessageBox::information ( QWidget parent,
const QString caption,
const QString text,
const QString button0Text = QString::null,
const QString button1Text = QString::null,
const QString button2Text = QString::null,
int  defaultButtonNumber = 0,
int  escapeButtonNumber = -1 
) [static]
int QMessageBox::information ( QWidget parent,
const QString caption,
const QString text,
const QString button0Text = QString::null,
const QString button1Text = QString::null,
const QString button2Text = QString::null,
int  defaultButtonNumber = 0,
int  escapeButtonNumber = -1 
) [static]

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Displays an information message box with caption caption, text text and one, two or three buttons. Returns the index of the button that was clicked (0, 1 or 2).

button0Text is the text of the first button, and is optional. If button0Text is not supplied, "OK" (translated) will be used. button1Text is the text of the second button, and is optional. button2Text is the text of the third button, and is optional. defaultButtonNumber (0, 1 or 2) is the index of the default button; pressing Return or Enter is the same as clicking the default button. It defaults to 0 (the first button). escapeButtonNumber is the index of the Escape button; pressing Escape is the same as clicking this button. It defaults to -1; supply 0, 1 or 2 to make pressing Escape equivalent to clicking the relevant button.

If parent is 0, the message box becomes an application-global modal dialog box. If parent is a widget, the message box becomes modal relative to parent.

Note: If you do not specify an Escape button then if the Escape button is pressed then -1 will be returned. It is suggested that you specify an Escape button to prevent this from happening.

Ver también:
question(), warning(), critical()
int QMessageBox::information ( QWidget parent,
const QString caption,
const QString text,
int  button0,
int  button1 = 0,
int  button2 = 0 
) [static]

Opens an information message box with the caption caption and the text text. The dialog may have up to three buttons. Each of the buttons, button0, button1 and button2 may be set to one of the following values:

QMessageBox::NoButton QMessageBox::Ok QMessageBox::Cancel QMessageBox::Yes QMessageBox::No QMessageBox::Abort QMessageBox::Retry QMessageBox::Ignore QMessageBox::YesAll QMessageBox::NoAll

If you don't want all three buttons, set the last button, or last two buttons to QMessageBox::NoButton.

One button can be OR-ed with QMessageBox::Default, and one button can be OR-ed with QMessageBox::Escape.

Returns the identity (QMessageBox::Ok, or QMessageBox::No, etc.) of the button that was clicked.

If parent is 0, the message box becomes an application-global modal dialog box. If parent is a widget, the message box becomes modal relative to parent.

Ver también:
question(), warning(), critical()
void QMessageBox::keyPressEvent ( QKeyEvent e) [protected, virtual]

Reimplementado de QDialog.

void QMessageBox::keyPressEvent ( QKeyEvent e) [protected, virtual]

Reimplementado de QDialog.

static int QMessageBox::message ( const QString caption,
const QString text,
const QString buttonText = QString::null,
QWidget parent = 0,
const char *  = 0 
) [inline, static]
int QMessageBox::message ( const QString caption,
const QString text,
const QString buttonText = QString::null,
QWidget parent = 0,
const char *  = 0 
) [inline, static]

Opens a modal message box directly using the specified parameters.

Please use information(), warning(), question(), or critical() instead.

static bool QMessageBox::query ( const QString caption,
const QString text,
const QString yesButtonText = QString::null,
const QString noButtonText = QString::null,
QWidget parent = 0,
const char *  = 0 
) [inline, static]
bool QMessageBox::query ( const QString caption,
const QString text,
const QString yesButtonText = QString::null,
const QString noButtonText = QString::null,
QWidget parent = 0,
const char *  = 0 
) [inline, static]

Queries the user using a modal message box with two buttons. Note that caption is not always shown, it depends on the window manager.

Please use information(), question(), warning(), or critical() instead.

int QMessageBox::question ( QWidget parent,
const QString caption,
const QString text,
const QString button0Text = QString::null,
const QString button1Text = QString::null,
const QString button2Text = QString::null,
int  defaultButtonNumber = 0,
int  escapeButtonNumber = -1 
) [static]

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Displays a question message box with caption caption, text text and one, two or three buttons. Returns the index of the button that was clicked (0, 1 or 2).

button0Text is the text of the first button, and is optional. If button0Text is not supplied, "OK" (translated) will be used. button1Text is the text of the second button, and is optional. button2Text is the text of the third button, and is optional. defaultButtonNumber (0, 1 or 2) is the index of the default button; pressing Return or Enter is the same as clicking the default button. It defaults to 0 (the first button). escapeButtonNumber is the index of the Escape button; pressing Escape is the same as clicking this button. It defaults to -1; supply 0, 1 or 2 to make pressing Escape equivalent to clicking the relevant button.

If parent is 0, the message box becomes an application-global modal dialog box. If parent is a widget, the message box becomes modal relative to parent.

Note: If you do not specify an Escape button then if the Escape button is pressed then -1 will be returned. It is suggested that you specify an Escape button to prevent this from happening.

Ver también:
information(), warning(), critical()
static int QMessageBox::question ( QWidget parent,
const QString caption,
const QString text,
int  button0,
int  button1 = 0,
int  button2 = 0 
) [static]
static int QMessageBox::question ( QWidget parent,
const QString caption,
const QString text,
const QString button0Text = QString::null,
const QString button1Text = QString::null,
const QString button2Text = QString::null,
int  defaultButtonNumber = 0,
int  escapeButtonNumber = -1 
) [static]
int QMessageBox::question ( QWidget parent,
const QString caption,
const QString text,
int  button0,
int  button1 = 0,
int  button2 = 0 
) [static]

Opens a question message box with the caption caption and the text text. The dialog may have up to three buttons. Each of the buttons, button0, button1 and button2 may be set to one of the following values:

QMessageBox::NoButton QMessageBox::Ok QMessageBox::Cancel QMessageBox::Yes QMessageBox::No QMessageBox::Abort QMessageBox::Retry QMessageBox::Ignore QMessageBox::YesAll QMessageBox::NoAll

If you don't want all three buttons, set the last button, or last two buttons to QMessageBox::NoButton.

One button can be OR-ed with QMessageBox::Default, and one button can be OR-ed with QMessageBox::Escape.

Returns the identity (QMessageBox::Yes, or QMessageBox::No, etc.) of the button that was clicked.

If parent is 0, the message box becomes an application-global modal dialog box. If parent is a widget, the message box becomes modal relative to parent.

Ver también:
information(), warning(), critical()
void QMessageBox::resizeEvent ( QResizeEvent ) [protected, virtual]

Reimplementado de QDialog.

void QMessageBox::resizeEvent ( QResizeEvent ) [protected, virtual]

Reimplementado de QDialog.

void QMessageBox::setButtonText ( int  button,
const QString text 
)

Sets the text of the message box button button to text. Setting the text of a button that is not in the message box is silently ignored.

Ver también:
buttonText()
void QMessageBox::setButtonText ( int  button,
const QString  
)
void QMessageBox::setIcon ( Icon  )
void QMessageBox::setIcon ( Icon  icon)
void QMessageBox::setIcon ( const QPixmap pix) [virtual]

Reimplementado de QWidget.

void QMessageBox::setIcon ( const QPixmap pixmap) [virtual]

Sets the window icon to pixmap.

Ver también:
icon(), setIconText(), setCaption(), Setting the Application Icon

Reimplementado de QWidget.

void QMessageBox::setIconPixmap ( const QPixmap pixmap)
void QMessageBox::setIconPixmap ( const QPixmap )
void QMessageBox::setText ( const QString text)
void QMessageBox::setText ( const QString )
void QMessageBox::setTextFormat ( Qt::TextFormat  format)
void QMessageBox::setTextFormat ( TextFormat  )
void QMessageBox::showEvent ( QShowEvent e) [protected, virtual]

Reimplementado de QWidget.

void QMessageBox::showEvent ( QShowEvent ) [protected, virtual]

This event handler can be reimplemented in a subclass to receive widget show events.

Non-spontaneous show events are sent to widgets immediately before they are shown. The spontaneous show events of top-level widgets are delivered afterwards.

Ver también:
event(), QShowEvent

Reimplementado de QWidget.

QPixmap QMessageBox::standardIcon ( Icon  icon,
GUIStyle  style 
) [static]

Returns the pixmap used for a standard icon. This allows the pixmaps to be used in more complex message boxes. icon specifies the required icon, e.g. QMessageBox::Information, QMessageBox::Warning or QMessageBox::Critical.

style is unused.

QPixmap QMessageBox::standardIcon ( Icon  icon) [static]

Returns the pixmap used for a standard icon. This allows the pixmaps to be used in more complex message boxes. icon specifies the required icon, e.g. QMessageBox::Question, QMessageBox::Information, QMessageBox::Warning or QMessageBox::Critical.

static QPixmap QMessageBox::standardIcon ( Icon  icon) [static]
static QPixmap QMessageBox::standardIcon ( Icon  icon,
GUIStyle   
) [static]
void QMessageBox::styleChanged ( QStyle ) [protected]
void QMessageBox::styleChanged ( QStyle ) [protected]
QString QMessageBox::text ( ) const
QString QMessageBox::text ( ) const
TextFormat QMessageBox::textFormat ( ) const
TextFormat QMessageBox::textFormat ( ) const
int QMessageBox::warning ( QWidget parent,
const QString caption,
const QString text,
int  button0,
int  button1,
int  button2 = 0 
) [static]

Opens a warning message box with the caption caption and the text text. The dialog may have up to three buttons. Each of the button parameters, button0, button1 and button2 may be set to one of the following values:

QMessageBox::NoButton QMessageBox::Ok QMessageBox::Cancel QMessageBox::Yes QMessageBox::No QMessageBox::Abort QMessageBox::Retry QMessageBox::Ignore QMessageBox::YesAll QMessageBox::NoAll

If you don't want all three buttons, set the last button, or last two buttons to QMessageBox::NoButton.

One button can be OR-ed with QMessageBox::Default, and one button can be OR-ed with QMessageBox::Escape.

Returns the identity (QMessageBox::Ok, or QMessageBox::No, etc.) of the button that was clicked.

If parent is 0, the message box becomes an application-global modal dialog box. If parent is a widget, the message box becomes modal relative to parent.

Ver también:
information(), question(), critical()
static int QMessageBox::warning ( QWidget parent,
const QString caption,
const QString text,
const QString button0Text = QString::null,
const QString button1Text = QString::null,
const QString button2Text = QString::null,
int  defaultButtonNumber = 0,
int  escapeButtonNumber = -1 
) [static]
int QMessageBox::warning ( QWidget parent,
const QString caption,
const QString text,
const QString button0Text = QString::null,
const QString button1Text = QString::null,
const QString button2Text = QString::null,
int  defaultButtonNumber = 0,
int  escapeButtonNumber = -1 
) [static]

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Displays a warning message box with a caption, a text, and 1, 2 or 3 buttons. Returns the number of the button that was clicked (0, 1, or 2).

button0Text is the text of the first button, and is optional. If button0Text is not supplied, "OK" (translated) will be used. button1Text is the text of the second button, and is optional, and button2Text is the text of the third button, and is optional. defaultButtonNumber (0, 1 or 2) is the index of the default button; pressing Return or Enter is the same as clicking the default button. It defaults to 0 (the first button). escapeButtonNumber is the index of the Escape button; pressing Escape is the same as clicking this button. It defaults to -1; supply 0, 1, or 2 to make pressing Escape equivalent to clicking the relevant button.

If parent is 0, the message box becomes an application-global modal dialog box. If parent is a widget, the message box becomes modal relative to parent.

Note: If you do not specify an Escape button then if the Escape button is pressed then -1 will be returned. It is suggested that you specify an Escape button to prevent this from happening.

Ver también:
information(), question(), critical()
static int QMessageBox::warning ( QWidget parent,
const QString caption,
const QString text,
int  button0,
int  button1,
int  button2 = 0 
) [static]

Documentación de propiedades

Icon QMessageBox::icon [read, write]

the message box's icon

The icon of the message box can be one of the following predefined icons: QMessageBox::NoIcon QMessageBox::Question QMessageBox::Information QMessageBox::Warning QMessageBox::Critical

The actual pixmap used for displaying the icon depends on the current GUI style. You can also set a custom pixmap icon using the QMessageBox::iconPixmap property. The default icon is QMessageBox::NoIcon.

Ver también:
iconPixmap

Reimplementado de QWidget.

QPixmap QMessageBox::iconPixmap [read, write]

the current icon

The icon currently used by the message box. Note that it's often hard to draw one pixmap that looks appropriate in both Motif and Windows GUI styles; you may want to draw two pixmaps.

Ver también:
icon
QString QMessageBox::text [read, write]

the message box text to be displayed.

The text will be interpreted either as a plain text or as rich text, depending on the text format setting ( QMessageBox::textFormat). The default setting is AutoText, i.e. the message box will try to auto-detect the format of the text.

The default value of this property is QString::null.

Ver también:
textFormat
TextFormat QMessageBox::textFormat [read, write]

the format of the text displayed by the message box

The current text format used by the message box. See the Qt::TextFormat enum for an explanation of the possible options.

The default format is AutoText.

Ver también:
setText()

La documentación para esta clase fue generada a partir de los siguientes ficheros:
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'