⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qmessagebox.3qt

📁 Qt/Embedded是一个多平台的C++图形用户界面应用程序框架
💻 3QT
📖 第 1 页 / 共 2 页
字号:
            // save and exit.br            break;.br        case QMessageBox::No:.br            // exit without saving.br            break;.br        case QMessageBox::Cancel:.br            // don't save and don't exit.br            break;.br    }.fi.PPQMessageBox defines two enum types, Icon and an unnamed button type. Icon defines the \fCInformation, Warning\fR and \fCCritical\fR icons for each GUI style. It is used by the constructor, by the static member functions information(), warning() and critical(), and there is a function called standardIcon() which gives you access to the various icons..PPThe button types are:.TP\fCOk\fR - the default for single-button message boxes.TP\fCCancel\fR - note that this is \fInot\fR automatically Escape.TP\fCYes\fR.TP\fCNo\fR.TP\fCAbort\fR.TP\fCRetry\fR.TP\fCIgnore\fR.PPButton types can be combined with two modifiers by using OR:.TP\fCDefault\fR - makes pressing Enter or Return be equivalent with clicking this button. Normally used with Ok, Yes or similar..TP\fCEscape\fR - makes pressing Escape be equivalent with this button. Normally used with Abort, Cancel or similar..PPThe text(), icon() and iconPixmap() functions provide access to the current text and pixmap of a message box, and setText(), setIcon() and setIconPixmap() lets you change it. The difference between setIcon() and setIconPixmap() is that the former accepts a QMessageBox::Icon and can it be used to set standard icons while 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<img src=qmsgbox-m.png> <img src=qmsgbox-w.png>.PPSee also QDialog, Isys on error messages, and GUI Design Handbook: Message Box..SS "Member Type Documentation".SH "QMessageBox::Icon"This type includes the following values:.TP\fCQMessageBox::NoIcon\fR.TP\fCQMessageBox::Information\fR.TP\fCQMessageBox::Warning\fR.TP\fCQMessageBox::Critical\fR.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 text "OK"..PPIf \fIparent\fR is 0, then 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:.TP\fCQMessageBox::NoIcon\fR.TP\fCQMessageBox::Information\fR.TP\fCQMessageBox::Warning\fR.TP\fCQMessageBox::Critical\fR.PPEach button can have one of the following values:.TP\fCQMessageBox::NoButton\fR.TP\fCQMessageBox::Ok\fR.TP\fCQMessageBox::Cancel\fR.TP\fCQMessageBox::Yes\fR.TP\fCQMessageBox::No\fR.TP\fCQMessageBox::Abort\fR.TP\fCQMessageBox::Retry\fR.TP\fCQMessageBox::Ignore\fR.PPUse QMessageBox::NoButton for the later parameters to have less than three buttons in your message box..PPOne of the buttons can be combined with the \fCQMessageBox::Default\fR flag to make a default button..PPOne of the buttons can be combined with the \fCQMessageBox::Escape\fR flag to make an escape option. Hitting the Esc key on the keyboard has the same effect as clicking this button with the mouse..PPExample:.PP.nf.br    QMessageBox mb( "Hardware failure",.br                    "Disk error detected\\nDo you want to stop?",.br                    QMessageBox::NoIcon,.br                    QMessageBox::Yes | QMessageBox::Default,.br                    QMessageBox::No | QMessageBox::Escape );.br    if ( mb.exec() == QMessageBox::No ).br        // try again.fi.PPIf \fIparent\fR is 0, then 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, name, modal\fR and \fIf\fR arguments are passed to the QDialog constructor..PPSee also setCaption(), setText() and setIcon()..SH "QMessageBox::~QMessageBox ()"Destructs the message box..SH "void QMessageBox::about ( QWidget * parent, const QString & caption, const QString & text ) \fC[static]\fR"Displays a simple about box with window caption \fIcaption\fR and body text \fItext.\fR.PPabout() looks for a suitable icon for the box in four locations:.IP 1It prefers parent->icon() if that exists. .IP 2If not, it tries the top level widget containing \fIparent\fR .IP 3If that too fails, it tries the main widget. .IP 4As 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:.(lmenu/menu.cpp.)l.SH "void QMessageBox::aboutQt ( QWidget * parent, const QString & caption=QString::null ) \fC[static]\fR"Displays a simple message box about Qt, with window caption \fIcaption\fR and optionally centered over \fIparent.\fR The message includes the version number of Qt being used by the application..PPThis is neat for inclusion into the Help menu. See the menu.cpp example..PPExamples:.(lmenu/menu.cpp trivial/trivial.cpp.)l.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, const QString & button0Text = QString::null, const QString & button1Text = QString::null, const QString & button2Text = QString::null, int defaultButtonNumber = 0, int escapeButtonNumber = -1 ) \fC[static]\fR"Displays a critical error message box with a caption, a text and 1-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-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 be equivalent with clicking the relevant button..PPIf \fIparent\fR is 0, then 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 "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 a caption, a text and up to three buttons. Returns the identifier of the button that was clicked..PPIf \fIparent\fR is 0, then 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 "QMessageBox::Icon QMessageBox::icon() const"Returns the icon of the message box..PPSee also setIcon() and iconPixmap()..SH "const QPixmap * QMessageBox::iconPixmap () const"Returns the icon pixmap of the message box..PPExample:.PP.nf.br    QMessageBox mb(...);.br    mb.setIcon( QMessageBox::Warning );.br    mb.iconPixmap();    // returns the warning icon pixmap.fi.PPSee also setIconPixmap() and icon()..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"Displays an information message box with a caption, a text and 1-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. \fIbutton2Text\fR is the text of the third button and is optional. \fIdefaultbuttonNumber\fR (0-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 be equivalent with clicking the relevant button..PPIf \fIparent\fR is 0, then 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:.(lpicture/picture.cpp.)l.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 a caption, a text and up to three buttons. Returns the identifier of the button that was clicked..PPIf \fIparent\fR is 0, then 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 "void QMessageBox::keyPressEvent ( QKeyEvent * e ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "void QMessageBox::resizeEvent ( QResizeEvent * ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..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 quietly ignored..PPSee also buttonText()..SH "void QMessageBox::setIcon ( Icon icon )"Sets the icon of the message box to \fIicon,\fR which is a predefined icon:.TP\fCQMessageBox::NoIcon\fR.TP\fCQMessageBox::Information\fR.TP\fCQMessageBox::Warning\fR.TP\fCQMessageBox::Critical\fR.PPThe actual pixmap used for displaying the icon depends on the current GUI style. You can also set a custom pixmap icon using the setIconPixmap() function..PPSee also icon(), setIconPixmap() and iconPixmap()..SH "void QMessageBox::setIcon ( const QPixmap & pix ) \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "void QMessageBox::setIconPixmap ( const QPixmap & pixmap )"Sets the icon of the message box to a custom \fIpixmap.\fR Note that it's often hard to draw one pixmap which looks appropriate in both Motif and Windoes GUI styles. You may want to draw two..PPSee also iconPixmap() and setIcon()..SH "void QMessageBox::setText ( const QString & text )"Sets the message box text to be displayed..PP\fItext\fR will be interpreted either as a plain text or as a rich text, depending on the text format setting; see setTextFormat(). The default setting is \fCAutoText,\fR i.e. the message box will try to auto-detect the format of \fItext.\fR.PPSee also text() and setTextFormat()..SH "void QMessageBox::setTextFormat ( Qt::TextFormat format )"Sets the text format to \fIformat.\fR See the Qt::TextFormat enum for an explanation of the possible options..PPThe default format is \fCAutoText.\fR.PPSee also textFormat() and setText()..SH "QPixmap QMessageBox::standardIcon ( Icon icon, GUIStyle style ) \fC[static]\fR"Returns the pixmap used for a standard icon. This allows the pixmaps to be used in more complex message boxes..SH "void QMessageBox::styleChanged ( QStyle & ) \fC[protected]\fR"Reimplemented for internal reasons; the API is not affected..SH "QString QMessageBox::text () const"Returns the message box text currently set, or a null string if no text has been set..PPSee also setText() and textFormat()..SH "Qt::TextFormat QMessageBox::textFormat() const"Returns the current text format..PPSee also setTextFormat()..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"Displays a warning message box with a caption, a text and 1-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-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 be equivalent with clicking the relevant button..PPIf \fIparent\fR is 0, then 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:.(li18n/main.cpp.)l.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 a caption, a text and up to three buttons. Returns the identifier of the button that was clicked..PPIf \fIparent\fR is 0, then 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()..SH "SEE ALSO".BR http://doc.trolltech.com/qmessagebox.html.SH COPYRIGHTCopyright 1992-2000 Trolltech AS, http://www.trolltech.com/.  See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -