📄 qmessagebox.3qt
字号:
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..PPsetButtonText() and buttonText() provide access to the buttons..PPQMessageBox has no signals or slots..PP.ce 1.B "[Image Omitted]".PP.ce 1.B "[Image Omitted]".PPSee also QDialog, Isys on error messages, GUI Design Handbook: Message Box, and Dialog Classes..SS "Member Type Documentation".SH "QMessageBox::Icon"This enum includes provides the following values:.TP\fCQMessageBox::NoIcon\fR - the message box does not have any icon..TP\fCQMessageBox::Information\fR - an icon indicating that the message is nothing out of the ordinary..TP\fCQMessageBox::Warning\fR - an icon indicating that the message is a warning, but can be dealt with..TP\fCQMessageBox::Critical\fR - an icon indicating that the message represents a critical problem..PP.SH MEMBER FUNCTION DOCUMENTATION.SH "QMessageBox::QMessageBox ( QWidget * parent = 0, const char * name = 0 )"Constructs a message box with no text and a button with the label "OK"..PPIf \fIparent\fR is 0, the message box becomes an application-global modal dialog box. If \fIparent\fR is a widget, the message box becomes modal relative to \fIparent\fR..PPThe \fIparent\fR and \fIname\fR arguments are passed to the QDialog constructor..SH "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 \fIcaption\fR, a \fItext\fR, an \fIicon\fR, and up to three buttons..PPThe \fIicon\fR must be one of the following:.TPQMessageBox::NoIcon.TPQMessageBox::Information.TPQMessageBox::Warning.TPQMessageBox::Critical.PPEach button, \fIbutton0\fR, \fIbutton1\fR and \fIbutton2\fR, can have one of the following values:.TPQMessageBox::NoButton.TPQMessageBox::Ok.TPQMessageBox::Cancel.TPQMessageBox::Yes.TPQMessageBox::No.TPQMessageBox::Abort.TPQMessageBox::Retry.TPQMessageBox::Ignore.PPUse QMessageBox::NoButton for the later parameters to have fewer than three buttons in your message box..PPOne of the buttons can be OR-ed with the \fCQMessageBox::Default\fR flag to make it the default button (clicked when Enter is pressed)..PPOne of the buttons can be OR-ed with the \fCQMessageBox::Escape\fR flag to make it the cancel or close button (clicked when Escape is pressed)..PPExample:.PP.nf.brQMessageBox mb( "Application Name",.br "Hardware failure.\\n\\nDisk error detected\\nDo you want to stop?",.br QMessageBox::NoIcon,.br QMessageBox::Yes | QMessageBox::Default,.br QMessageBox::No | QMessageBox::Escape.br QMessageBox::NoButton );.brif ( mb.exec() == QMessageBox::No ).br // try again.fi.PPIf \fIparent\fR is 0, the message box becomes an application-global modal dialog box. If \fIparent\fR is a widget, the message box becomes modal relative to \fIparent\fR..PPIf \fImodal\fR is TRUE the message becomes modal; otherwise it becomes modeless..PPThe \fIparent\fR, \fIname\fR, \fImodal\fR, and \fIf\fR arguments are passed to the QDialog constructor..PPSee also caption, text, and icon..SH "QMessageBox::~QMessageBox ()"Destroys the message box..SH "void QMessageBox::about ( QWidget * parent, const QString & caption, const QString & text )\fC [static]\fR"Displays a simple about box with caption \fIcaption\fR and text \fItext\fR. The about box's parent is \fIparent\fR..PPabout() looks for a suitable icon in four locations: <ol type=1>.TPIt prefers parent->icon() if that exists..TPIf not, it tries the top-level widget containing \fIparent\fR..TPIf that fails, it tries the main widget..TPAs a last resort it uses the Information icon..PPThe about box has a single button labelled OK..PPSee also QWidget::icon and QApplication::mainWidget()..PPExamples:.)l action/application.cpp, application/application.cpp, chart/chartform.cpp, helpviewer/helpwindow.cpp, mdi/application.cpp, menu/menu.cpp, and themes/themes.cpp..SH "void QMessageBox::aboutQt ( QWidget * parent, const QString & caption = QString::null )\fC [static]\fR"Displays a simple message box about Qt, with caption \fIcaption\fR and centered over \fIparent\fR (if \fIparent\fR is not 0). The message includes the version number of Qt being used by the application..PPThis is useful for inclusion in the Help menu. See the examples/menu/menu.cpp example..PPExamples:.)l action/application.cpp, application/application.cpp, chart/chartform.cpp, dialog/mainwindow.cpp, helpviewer/helpwindow.cpp, menu/menu.cpp, and themes/themes.cpp..SH "void QMessageBox::adjustSize ()\fC [virtual]\fR"Adjusts the size of the message box to fit the contents just before QDialog::exec() or QDialog::show() is called..PPThis function will not be called if the message box has been explicitly resized before showing it..PPReimplemented from QWidget..SH "QString QMessageBox::buttonText ( int button ) const"Returns the text of the message box button \fIbutton\fR, or null if the message box does not contain the button..PPSee also setButtonText()..SH "int QMessageBox::critical ( QWidget * parent, const QString & caption, const QString & text, int button0, int button1, int button2 = 0 )\fC [static]\fR"Opens a critical message box with the caption \fIcaption\fR and the text \fItext\fR. The dialog may have up to three buttons. Each of the button parameters, \fIbutton0\fR, \fIbutton1\fR and \fIbutton2\fR may be set to one of the following values:.TPQMessageBox::NoButton.TPQMessageBox::Ok.TPQMessageBox::Cancel.TPQMessageBox::Yes.TPQMessageBox::No.TPQMessageBox::Abort.TPQMessageBox::Retry.TPQMessageBox::Ignore.PPIf you don't want all three buttons, set the last button, or last two buttons to QMessageBox::NoButton..PPReturns the identity (QMessageBox::Ok, or QMessageBox::No, etc.) of the button that was clicked..PPIf \fIparent\fR is 0, the message box becomes an application-global modal dialog box. If \fIparent\fR is a widget, the message box becomes modal relative to \fIparent\fR..PPSee also information() and warning()..PPExamples:.)l network/ftpclient/ftpmainwindow.ui.h, process/process.cpp, and xml/outliner/outlinetree.cpp..SH "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 )\fC [static]\fR"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPDisplays 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)..PP\fIbutton0Text\fR is the text of the first button, and is optional. If \fIbutton0Text\fR is not supplied, "OK" (translated) will be used. \fIbutton1Text\fR is the text of the second button, and is optional, and \fIbutton2Text\fR is the text of the third button, and is optional. \fIdefaultButtonNumber\fR (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). \fIescapeButtonNumber\fR is the index of the Escape button; pressing Escape is the same as clicking this button. It defaults to -1 (pressing Escape does nothing); supply 0, 1, or 2 to make pressing Escape equivalent to clicking the relevant button..PPIf \fIparent\fR is 0, the message box becomes an application-global modal dialog box. If \fIparent\fR is a widget, the message box becomes modal relative to \fIparent\fR..PPSee also information() and warning()..SH "Icon QMessageBox::icon () const"Returns the message box's icon. See the "icon" property for details..SH "const QPixmap * QMessageBox::iconPixmap () const"Returns the current icon. See the "iconPixmap" property for details..SH "int QMessageBox::information ( QWidget * parent, const QString & caption, const QString & text, int button0, int button1 = 0, int button2 = 0 )\fC [static]\fR"Opens an information message box with the caption \fIcaption\fR and the text \fItext\fR. The dialog may have up to three buttons. Each of the buttons, \fIbutton0\fR, \fIbutton1\fR and \fIbutton2\fR may be set to one of the following values:.TPQMessageBox::NoButton.TPQMessageBox::Ok.TPQMessageBox::Cancel.TPQMessageBox::Yes.TPQMessageBox::No.TPQMessageBox::Abort.TPQMessageBox::Retry.TPQMessageBox::Ignore.PPIf you don't want all three buttons, set the last button, or last two buttons to QMessageBox::NoButton..PPReturns the identity (QMessageBox::Ok, or QMessageBox::No, etc.) of the button that was clicked..PPIf \fIparent\fR is 0, the message box becomes an application-global modal dialog box. If \fIparent\fR is a widget, the message box becomes modal relative to \fIparent\fR..PPSee also warning() and critical()..PPExamples:.)l action/application.cpp, application/application.cpp, dirview/dirview.cpp, fileiconview/qfileiconview.cpp, picture/picture.cpp, qwerty/qwerty.cpp, and sql/sqltable/main.cpp..SH "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 )\fC [static]\fR"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPDisplays an information message box with caption \fIcaption\fR, text \fItext\fR and one, two or three buttons. Returns the index of the button that was clicked (0, 1 or 2)..PP\fIbutton0Text\fR is the text of the first button, and is optional. If \fIbutton0Text\fR is not supplied, "OK" (translated) will be used. \fIbutton1Text\fR is the text of the second button, and is optional. \fIbutton2Text\fR is the text of the third button, and is optional. \fIdefaultButtonNumber\fR (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). \fIescapeButtonNumber\fR is the index of the Escape button; pressing Escape is the same as clicking this button. It defaults to -1 (pressing Escape does nothing); supply 0, 1 or 2 to make pressing Escape equivalent to clicking the relevant button..PPIf \fIparent\fR is 0, the message box becomes an application-global modal dialog box. If \fIparent\fR is a widget, the message box becomes modal relative to \fIparent\fR..PPSee also warning() and critical()..SH "int QMessageBox::message ( const QString & caption, const QString & text, const QString & buttonText = QString::null, QWidget * parent = 0, const char * = 0 )\fC [static]\fR"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPOpens a modal message box directly using the specified parameters..PPPlease use information(), warning() or critical() instead..SH "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 )\fC [static]\fR"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPQueries the user using a modal message box with two buttons. Note that \fIcaption\fR is not always shown, it depends on the window manager..PPPlease use information(), warning() or critical() instead..SH "void QMessageBox::setButtonText ( int button, const QString & text )"Sets the text of the message box button \fIbutton\fR to \fItext\fR. Setting the text of a button that is not in the message box is silently ignored..PPSee also buttonText()..SH "void QMessageBox::setIcon ( Icon )"Sets the message box's icon. See the "icon" property for details..SH "void QMessageBox::setIconPixmap ( const QPixmap & )"Sets the current icon. See the "iconPixmap" property for details..SH "void QMessageBox::setText ( const QString & )"Sets the message box text to be displayed. See the "text" property for details..SH "void QMessageBox::setTextFormat ( TextFormat )"Sets the format of the text displayed by the message box. See the "textFormat" property for details..SH "QPixmap QMessageBox::standardIcon ( Icon icon )\fC [static]\fR"Returns the pixmap used for a standard icon. This allows the pixmaps to be used in more complex message boxes. \fIicon\fR specifies the required icon, e.g. QMessageBox::Information, QMessageBox::Warning or QMessageBox::Critical..SH "QPixmap QMessageBox::standardIcon ( Icon icon, GUIStyle style )\fC [static]\fR"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPReturns the pixmap used for a standard icon. This allows the pixmaps to be used in more complex message boxes. \fIicon\fR specifies the required icon, e.g. QMessageBox::Information, QMessageBox::Warning or QMessageBox::Critical..PP\fIstyle\fR is unused..SH "QString QMessageBox::text () const"Returns the message box text to be displayed. See the "text" property for details..SH "TextFormat QMessageBox::textFormat () const"Returns the format of the text displayed by the message box. See the "textFormat" property for details..SH "int QMessageBox::warning ( QWidget * parent, const QString & caption, const QString & text, int button0, int button1, int button2 = 0 )\fC [static]\fR"Opens a warning message box with the caption \fIcaption\fR and the text \fItext\fR. The dialog may have up to three buttons. Each of the button parameters, \fIbutton0\fR, \fIbutton1\fR and \fIbutton2\fR may be set to one of the following values:.TPQMessageBox::NoButton.TPQMessageBox::Ok.TPQMessageBox::Cancel.TPQMessageBox::Yes.TPQMessageBox::No.TPQMessageBox::Abort.TPQMessageBox::Retry.TPQMessageBox::Ignore.PPIf you don't want all three buttons, set the last button, or last two buttons to QMessageBox::NoButton..PPReturns the identity (QMessageBox::Ok, or QMessageBox::No, etc.) of the button that was clicked..PPIf \fIparent\fR is 0, the message box becomes an application-global modal dialog box. If \fIparent\fR is a widget, the message box becomes modal relative to \fIparent\fR..PPSee also information() and critical()..PPExamples:.)l chart/chartform.cpp, i18n/main.cpp, network/mail/smtp.cpp, qwerty/qwerty.cpp, showimg/showimg.cpp, and sound/sound.cpp..SH "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 )\fC [static]\fR"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPDisplays 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)..PP\fIbutton0Text\fR is the text of the first button, and is optional. If \fIbutton0Text\fR is not supplied, "OK" (translated) will be used. \fIbutton1Text\fR is the text of the second button, and is optional, and \fIbutton2Text\fR is the text of the third button, and is optional. \fIdefaultButtonNumber\fR (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). \fIescapeButtonNumber\fR is the index of the Escape button; pressing Escape is the same as clicking this button. It defaults to -1 (pressing Escape does nothing); supply 0, 1, or 2 to make pressing Escape equivalent to clicking the relevant button..PPIf \fIparent\fR is 0, the message box becomes an application-global modal dialog box. If \fIparent\fR is a widget, the message box becomes modal relative to \fIparent\fR..PPSee also information() and critical()..SS "Property Documentation".SH "Icon icon"This property holds the message box's icon..PPThe icon of the message box can be one of the following predefined icons:.TPQMessageBox::NoIcon.TPQMessageBox::Information.TPQMessageBox::Warning.TPQMessageBox::Critical.PPThe 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..PPSee also iconPixmap..PPSet this property's value with setIcon() and get this property's value with icon()..SH "QPixmap iconPixmap"This property holds the current icon..PPThe 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..PPSee also icon..PPSet this property's value with setIconPixmap() and get this property's value with iconPixmap()..SH "QString text"This property holds the message box text to be displayed..PPThe 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..PPThe default value of this property is QString::null..PPSee also textFormat..PPSet this property's value with setText() and get this property's value with text()..SH "TextFormat textFormat"This property holds the format of the text displayed by the message box..PPThe current text format used by the message box. See the Qt::TextFormat enum for an explanation of the possible options..PPThe default format is AutoText..PPSee also text..PPSet this property's value with setTextFormat() and get this property's value with textFormat()..SH "SEE ALSO".BR http://doc.trolltech.com/qmessagebox.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com. See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf you find a bug in Qt, please report it as described in.BR http://doc.trolltech.com/bughowto.html .Good bug reports help us to help you. Thank you..PThe definitive Qt documentation is provided in HTML format; it islocated at $QTDIR/doc/html and can be read using Qt Assistant or witha web browser. This man page is provided as a convenience for thoseusers who prefer man pages, although this format is not officiallysupported by Trolltech. .PIf you find errors in this manual page, please report them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qmessagebox.3qt) and the Qtversion (3.1.1).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -