You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
752 lines
48 KiB
752 lines
48 KiB
14 years ago
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||
|
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/dialogs/qmessagebox.cpp:149 -->
|
||
|
<html>
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||
|
<title>QMessageBox Class</title>
|
||
|
<style type="text/css"><!--
|
||
|
fn { margin-left: 1cm; text-indent: -1cm; }
|
||
|
a:link { color: #004faf; text-decoration: none }
|
||
|
a:visited { color: #672967; text-decoration: none }
|
||
|
body { background: #ffffff; color: black; }
|
||
|
--></style>
|
||
|
</head>
|
||
|
<body>
|
||
|
|
||
|
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
||
|
<tr bgcolor="#E5E5E5">
|
||
|
<td valign=center>
|
||
|
<a href="index.html">
|
||
|
<font color="#004faf">Home</font></a>
|
||
|
| <a href="classes.html">
|
||
|
<font color="#004faf">All Classes</font></a>
|
||
|
| <a href="mainclasses.html">
|
||
|
<font color="#004faf">Main Classes</font></a>
|
||
|
| <a href="annotated.html">
|
||
|
<font color="#004faf">Annotated</font></a>
|
||
|
| <a href="groups.html">
|
||
|
<font color="#004faf">Grouped Classes</font></a>
|
||
|
| <a href="functions.html">
|
||
|
<font color="#004faf">Functions</font></a>
|
||
|
</td>
|
||
|
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QMessageBox Class Reference</h1>
|
||
|
|
||
|
<p>The QMessageBox class provides a modal dialog with a short message, an icon, and some buttons.
|
||
|
<a href="#details">More...</a>
|
||
|
<p><tt>#include <<a href="qmessagebox-h.html">qmessagebox.h</a>></tt>
|
||
|
<p>Inherits <a href="qdialog.html">QDialog</a>.
|
||
|
<p><a href="qmessagebox-members.html">List of all member functions.</a>
|
||
|
<h2>Public Members</h2>
|
||
|
<ul>
|
||
|
<li class=fn>enum <a href="#Icon-enum"><b>Icon</b></a> { NoIcon = 0, Information = 1, Warning = 2, Critical = 3, Question = 4 }</li>
|
||
|
<li class=fn><a href="#QMessageBox"><b>QMessageBox</b></a> ( QWidget * parent = 0, const char * name = 0 )</li>
|
||
|
<li class=fn><a href="#QMessageBox-2"><b>QMessageBox</b></a> ( 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 )</li>
|
||
|
<li class=fn><a href="#~QMessageBox"><b>~QMessageBox</b></a> ()</li>
|
||
|
<li class=fn>QString <a href="#text"><b>text</b></a> () const</li>
|
||
|
<li class=fn>void <a href="#setText"><b>setText</b></a> ( const QString & )</li>
|
||
|
<li class=fn>Icon <a href="#icon"><b>icon</b></a> () const</li>
|
||
|
<li class=fn>void <a href="#setIcon"><b>setIcon</b></a> ( Icon )</li>
|
||
|
<li class=fn>const QPixmap * <a href="#iconPixmap"><b>iconPixmap</b></a> () const</li>
|
||
|
<li class=fn>void <a href="#setIconPixmap"><b>setIconPixmap</b></a> ( const QPixmap & )</li>
|
||
|
<li class=fn>QString <a href="#buttonText"><b>buttonText</b></a> ( int button ) const</li>
|
||
|
<li class=fn>void <a href="#setButtonText"><b>setButtonText</b></a> ( int button, const QString & text )</li>
|
||
|
<li class=fn>virtual void <a href="#adjustSize"><b>adjustSize</b></a> ()</li>
|
||
|
<li class=fn>TextFormat <a href="#textFormat"><b>textFormat</b></a> () const</li>
|
||
|
<li class=fn>void <a href="#setTextFormat"><b>setTextFormat</b></a> ( TextFormat )</li>
|
||
|
</ul>
|
||
|
<h2>Static Public Members</h2>
|
||
|
<ul>
|
||
|
<li class=fn>int <a href="#information"><b>information</b></a> ( QWidget * parent, const QString & caption, const QString & text, int button0, int button1 = 0, int button2 = 0 )</li>
|
||
|
<li class=fn>int <a href="#information-2"><b>information</b></a> ( 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 )</li>
|
||
|
<li class=fn>int <a href="#question"><b>question</b></a> ( QWidget * parent, const QString & caption, const QString & text, int button0, int button1 = 0, int button2 = 0 )</li>
|
||
|
<li class=fn>int <a href="#question-2"><b>question</b></a> ( 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 )</li>
|
||
|
<li class=fn>int <a href="#warning"><b>warning</b></a> ( QWidget * parent, const QString & caption, const QString & text, int button0, int button1, int button2 = 0 )</li>
|
||
|
<li class=fn>int <a href="#warning-2"><b>warning</b></a> ( 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 )</li>
|
||
|
<li class=fn>int <a href="#critical"><b>critical</b></a> ( QWidget * parent, const QString & caption, const QString & text, int button0, int button1, int button2 = 0 )</li>
|
||
|
<li class=fn>int <a href="#critical-2"><b>critical</b></a> ( 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 )</li>
|
||
|
<li class=fn>void <a href="#about"><b>about</b></a> ( QWidget * parent, const QString & caption, const QString & text )</li>
|
||
|
<li class=fn>void <a href="#aboutQt"><b>aboutQt</b></a> ( QWidget * parent, const QString & caption = QString::null )</li>
|
||
|
<li class=fn>int message ( const QString & caption, const QString & text, const QString & buttonText = QString::null, QWidget * parent = 0, const char * = 0 ) <em>(obsolete)</em></li>
|
||
|
<li class=fn>bool query ( const QString & caption, const QString & text, const QString & yesButtonText = QString::null, const QString & noButtonText = QString::null, QWidget * parent = 0, const char * = 0 ) <em>(obsolete)</em></li>
|
||
|
<li class=fn>QPixmap standardIcon ( Icon icon, GUIStyle style ) <em>(obsolete)</em></li>
|
||
|
<li class=fn>QPixmap <a href="#standardIcon"><b>standardIcon</b></a> ( Icon icon )</li>
|
||
|
</ul>
|
||
|
<h2>Properties</h2>
|
||
|
<ul>
|
||
|
<li class=fn>Icon <a href="#icon-prop"><b>icon</b></a> - the message box's icon</li>
|
||
|
<li class=fn>QPixmap <a href="#iconPixmap-prop"><b>iconPixmap</b></a> - the current icon</li>
|
||
|
<li class=fn>QString <a href="#text-prop"><b>text</b></a> - the message box text to be displayed</li>
|
||
|
<li class=fn>TextFormat <a href="#textFormat-prop"><b>textFormat</b></a> - the format of the text displayed by the message box</li>
|
||
|
</ul>
|
||
|
<hr><a name="details"></a><h2>Detailed Description</h2>
|
||
|
|
||
|
|
||
|
The QMessageBox class provides a modal dialog with a short message, an icon, and some buttons.
|
||
|
|
||
|
|
||
|
<p> Message boxes are used to provide informative messages and to ask
|
||
|
simple questions.
|
||
|
<p> QMessageBox provides a range of different messages, arranged
|
||
|
roughly along two axes: severity and complexity.
|
||
|
<p> Severity is
|
||
|
<center><table cellpadding="4" cellspacing="2" border="0">
|
||
|
<tr bgcolor="#f0f0f0">
|
||
|
<td valign="top"><center><img src="qmessagebox-quest.png"></center> <td valign="top">Question
|
||
|
<td valign="top">For message boxes that ask a question as part of normal
|
||
|
operation. Some style guides recommend using Information for this
|
||
|
purpose.
|
||
|
<tr bgcolor="#d0d0d0">
|
||
|
<td valign="top"><center><img src="qmessagebox-info.png"></center> <td valign="top">Information
|
||
|
<td valign="top">For message boxes that are part of normal operation.
|
||
|
<tr bgcolor="#f0f0f0">
|
||
|
<td valign="top"><center><img src="qmessagebox-warn.png"></center> <td valign="top">Warning
|
||
|
<td valign="top">For message boxes that tell the user about unusual errors.
|
||
|
<tr bgcolor="#d0d0d0">
|
||
|
<td valign="top"><center><img src="qmessagebox-crit.png"></center> <td valign="top">Critical
|
||
|
<td valign="top">For message boxes that tell the user about critical errors.
|
||
|
</table></center>
|
||
|
<p> The message box has a different icon for each of the severity levels.
|
||
|
<p> Complexity is one button (OK) for simple messages, or two or even
|
||
|
three buttons for questions.
|
||
|
<p> There are static functions for the most common cases.
|
||
|
<p> Examples:
|
||
|
<p> If a program is unable to find a supporting file, but can do perfectly
|
||
|
well without it:
|
||
|
<p> <pre>
|
||
|
QMessageBox::<a href="#information">information</a>( this, "Application name",
|
||
|
"Unable to find the user preferences file.\n"
|
||
|
"The factory default will be used instead." );
|
||
|
</pre>
|
||
|
|
||
|
<p> <a href="#question">question</a>() is useful for simple yes/no questions:
|
||
|
<p> <pre>
|
||
|
if ( QFile::<a href="qfile.html#exists">exists</a>( filename ) &&
|
||
|
QMessageBox::<a href="#question">question</a>(
|
||
|
this,
|
||
|
<a href="qobject.html#tr">tr</a>("Overwrite File? -- Application Name"),
|
||
|
<a href="qobject.html#tr">tr</a>("A file called %1 already exists."
|
||
|
"Do you want to overwrite it?")
|
||
|
.arg( filename ),
|
||
|
<a href="qobject.html#tr">tr</a>("&Yes"), tr("&No"),
|
||
|
<a href="qstring.html#QString-null">QString::null</a>, 0, 1 ) )
|
||
|
return false;
|
||
|
</pre>
|
||
|
|
||
|
<p> <a href="#warning">warning</a>() can be used to tell the user about unusual errors, or
|
||
|
errors which can't be easily fixed:
|
||
|
<p> <pre>
|
||
|
switch( QMessageBox::<a href="#warning">warning</a>( 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;
|
||
|
}
|
||
|
</pre>
|
||
|
|
||
|
<p> 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
|
||
|
<a href="qstylesheet.html#defaultSheet">QStyleSheet::defaultSheet</a>() 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 <a href="qstylesheet.html#convertFromPlainText">QStyleSheet::convertFromPlainText</a>() to convert
|
||
|
your plain text string to a visually equivalent rich text string
|
||
|
or set the text format explicitly with <a href="#setTextFormat">setTextFormat</a>().
|
||
|
<p> Note that the Microsoft Windows User Interface Guidelines
|
||
|
recommend using the application name as the window's caption.
|
||
|
<p> 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.
|
||
|
<p> 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:
|
||
|
<p> <pre>
|
||
|
switch( QMessageBox::<a href="#information">information</a>( 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;
|
||
|
}
|
||
|
</pre>
|
||
|
|
||
|
<p> The Escape button cancels the entire exit operation, and pressing
|
||
|
Enter causes the changes to be saved before the exit occurs.
|
||
|
<p> Disk full errors are unusual and they certainly can be hard to
|
||
|
correct. This example uses predefined buttons instead of
|
||
|
hard-coded button texts:
|
||
|
<p> <pre>
|
||
|
switch( QMessageBox::<a href="#warning">warning</a>( 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;
|
||
|
}
|
||
|
</pre>
|
||
|
|
||
|
<p> The <a href="#critical">critical</a>() function should be reserved for critical errors. In
|
||
|
this example errorDetails is a <a href="qstring.html">QString</a> or const char*, and QString
|
||
|
is used to concatenate several strings:
|
||
|
<p> <pre>
|
||
|
QMessageBox::<a href="#critical">critical</a>( 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." );
|
||
|
</pre>
|
||
|
|
||
|
<p> In this example an OK button is displayed.
|
||
|
<p> QMessageBox provides a very simple About box which displays an
|
||
|
appropriate icon and the string you provide:
|
||
|
<p> <pre>
|
||
|
QMessageBox::<a href="#about">about</a>( 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" );
|
||
|
</pre>
|
||
|
|
||
|
<p> See <a href="#about">about</a>() for more information.
|
||
|
<p> 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
|
||
|
<a href="#aboutQt">aboutQt</a>().
|
||
|
<p> If none of the standard message boxes is suitable, you can create a
|
||
|
QMessageBox from scratch and use custom button texts:
|
||
|
<p> <pre>
|
||
|
QMessageBox mb( "Application name here",
|
||
|
"Saving the file will overwrite the original file on the disk.\n"
|
||
|
"Do you really want to save?",
|
||
|
QMessageBox::<a href="#Icon-enum">Information</a>,
|
||
|
QMessageBox::Yes | QMessageBox::Default,
|
||
|
QMessageBox::No,
|
||
|
QMessageBox::Cancel | QMessageBox::Escape );
|
||
|
mb.<a href="#setButtonText">setButtonText</a>( QMessageBox::Yes, "Save" );
|
||
|
mb.<a href="#setButtonText">setButtonText</a>( QMessageBox::No, "Discard" );
|
||
|
switch( mb.<a href="qdialog.html#exec">exec</a>() ) {
|
||
|
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;
|
||
|
}
|
||
|
</pre>
|
||
|
|
||
|
<p> QMessageBox defines two enum types: Icon and an unnamed button type.
|
||
|
Icon defines the <a href="#Icon-enum">Question</a>, <a href="#Icon-enum">Information</a>, <a href="#Icon-enum">Warning</a>, and <a href="#Icon-enum">Critical</a> icons for each GUI style. It is used by the constructor
|
||
|
and by the static member functions <a href="#question">question</a>(), <a href="#information">information</a>(),
|
||
|
<a href="#warning">warning</a>() and <a href="#critical">critical</a>(). A function called <a href="#standardIcon">standardIcon</a>() gives
|
||
|
you access to the various icons.
|
||
|
<p> The button types are:
|
||
|
<ul>
|
||
|
<li> Ok - the default for single-button message boxes
|
||
|
<li> Cancel - note that this is <em>not</em> automatically Escape
|
||
|
<li> Yes
|
||
|
<li> No
|
||
|
<li> Abort
|
||
|
<li> Retry
|
||
|
<li> Ignore
|
||
|
<li> YesAll
|
||
|
<li> NoAll
|
||
|
</ul>
|
||
|
<p> Button types can be combined with two modifiers by using OR, '|':
|
||
|
<ul>
|
||
|
<li> Default - makes pressing Enter equivalent to
|
||
|
clicking this button. Normally used with Ok, Yes or similar.
|
||
|
<li> Escape - makes pressing Escape equivalent to clicking this button.
|
||
|
Normally used with Abort, Cancel or similar.
|
||
|
</ul>
|
||
|
<p> The <a href="#text">text</a>(), <a href="#icon">icon</a>() and <a href="#iconPixmap">iconPixmap</a>() functions provide access to the
|
||
|
current text and pixmap of the message box. The <a href="#setText">setText</a>(), <a href="#setIcon">setIcon</a>()
|
||
|
and <a href="#setIconPixmap">setIconPixmap</a>() 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 <a href="qpixmap.html">QPixmap</a> and can be used to set custom icons.
|
||
|
<p> <a href="#setButtonText">setButtonText</a>() and <a href="#buttonText">buttonText</a>() provide access to the buttons.
|
||
|
<p> QMessageBox has no signals or slots.
|
||
|
<p> <img src=qmsgbox-m.png> <img src=qmsgbox-w.png>
|
||
|
<p> <p>See also <a href="qdialog.html">QDialog</a>, <a href="http://www.iarchitect.com/errormsg.htm
|
||
|
">Isys on error messages</a>, <a href="guibooks.html#fowler">GUI Design Handbook: Message Box</a>, and <a href="dialogs.html">Dialog Classes</a>.
|
||
|
|
||
|
<hr><h2>Member Type Documentation</h2>
|
||
|
<h3 class=fn><a name="Icon-enum"></a>QMessageBox::Icon</h3>
|
||
|
|
||
|
<p> This enum has the following values:
|
||
|
<ul>
|
||
|
<li><tt>QMessageBox::NoIcon</tt> - the message box does not have any icon.
|
||
|
<li><tt>QMessageBox::Question</tt> - an icon indicating that
|
||
|
the message is asking a question.
|
||
|
<li><tt>QMessageBox::Information</tt> - an icon indicating that
|
||
|
the message is nothing out of the ordinary.
|
||
|
<li><tt>QMessageBox::Warning</tt> - an icon indicating that the
|
||
|
message is a warning, but can be dealt with.
|
||
|
<li><tt>QMessageBox::Critical</tt> - an icon indicating that
|
||
|
the message represents a critical problem.
|
||
|
</ul><p>
|
||
|
<hr><h2>Member Function Documentation</h2>
|
||
|
<h3 class=fn><a name="QMessageBox"></a>QMessageBox::QMessageBox ( <a href="qwidget.html">QWidget</a> * parent = 0, const char * name = 0 )
|
||
|
</h3>
|
||
|
Constructs a message box with no text and a button with the label
|
||
|
"OK".
|
||
|
<p> If <em>parent</em> is 0, the message box becomes an application-global
|
||
|
modal dialog box. If <em>parent</em> is a widget, the message box
|
||
|
becomes modal relative to <em>parent</em>.
|
||
|
<p> The <em>parent</em> and <em>name</em> arguments are passed to the <a href="qdialog.html">QDialog</a>
|
||
|
constructor.
|
||
|
|
||
|
<h3 class=fn><a name="QMessageBox-2"></a>QMessageBox::QMessageBox ( const <a href="qstring.html">QString</a> & caption, const <a href="qstring.html">QString</a> & text, <a href="qmessagebox.html#Icon-enum">Icon</a> icon, int button0, int button1, int button2, <a href="qwidget.html">QWidget</a> * parent = 0, const char * name = 0, bool modal = TRUE, WFlags f = WStyle_DialogBorder )
|
||
|
</h3>
|
||
|
Constructs a message box with a <em>caption</em>, a <em>text</em>, an <em>icon</em>,
|
||
|
and up to three buttons.
|
||
|
<p> The <em>icon</em> must be one of the following:
|
||
|
<ul>
|
||
|
<li> QMessageBox::NoIcon
|
||
|
<li> QMessageBox::Question
|
||
|
<li> QMessageBox::Information
|
||
|
<li> QMessageBox::Warning
|
||
|
<li> QMessageBox::Critical
|
||
|
</ul>
|
||
|
<p> Each button, <em>button0</em>, <em>button1</em> and <em>button2</em>, can have one
|
||
|
of the following values:
|
||
|
<ul>
|
||
|
<li> QMessageBox::NoButton
|
||
|
<li> QMessageBox::Ok
|
||
|
<li> QMessageBox::Cancel
|
||
|
<li> QMessageBox::Yes
|
||
|
<li> QMessageBox::No
|
||
|
<li> QMessageBox::Abort
|
||
|
<li> QMessageBox::Retry
|
||
|
<li> QMessageBox::Ignore
|
||
|
<li> QMessageBox::YesAll
|
||
|
<li> QMessageBox::NoAll
|
||
|
</ul>
|
||
|
<p> 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.
|
||
|
<p> One of the buttons can be OR-ed with the <tt>QMessageBox::Default</tt>
|
||
|
flag to make it the default button (clicked when Enter is
|
||
|
pressed).
|
||
|
<p> One of the buttons can be OR-ed with the <tt>QMessageBox::Escape</tt>
|
||
|
flag to make it the cancel or close button (clicked when Escape is
|
||
|
pressed).
|
||
|
<p> Example:
|
||
|
<pre>
|
||
|
QMessageBox mb( "Application Name",
|
||
|
"Hardware failure.\n\nDisk error detected\nDo you want to stop?",
|
||
|
QMessageBox::<a href="#Icon-enum">Question</a>,
|
||
|
QMessageBox::Yes | QMessageBox::Default,
|
||
|
QMessageBox::No | QMessageBox::Escape,
|
||
|
QMessageBox::<a href="qt.html#ButtonState-enum">NoButton</a> );
|
||
|
if ( mb.<a href="qdialog.html#exec">exec</a>() == QMessageBox::No )
|
||
|
// try again
|
||
|
</pre>
|
||
|
|
||
|
<p> If <em>parent</em> is 0, the message box becomes an application-global
|
||
|
modal dialog box. If <em>parent</em> is a widget, the message box
|
||
|
becomes modal relative to <em>parent</em>.
|
||
|
<p> If <em>modal</em> is TRUE the message box is modal; otherwise it
|
||
|
is modeless.
|
||
|
<p> The <em>parent</em>, <em>name</em>, <em>modal</em>, and <em>f</em> arguments are passed to
|
||
|
the <a href="qdialog.html">QDialog</a> constructor.
|
||
|
<p> <p>See also <a href="qwidget.html#caption-prop">caption</a>, <a href="#text-prop">text</a>, and <a href="#icon-prop">icon</a>.
|
||
|
|
||
|
<h3 class=fn><a name="~QMessageBox"></a>QMessageBox::~QMessageBox ()
|
||
|
</h3>
|
||
|
Destroys the message box.
|
||
|
|
||
|
<h3 class=fn>void <a name="about"></a>QMessageBox::about ( <a href="qwidget.html">QWidget</a> * parent, const <a href="qstring.html">QString</a> & caption, const <a href="qstring.html">QString</a> & text )<tt> [static]</tt>
|
||
|
</h3>
|
||
|
Displays a simple about box with caption <em>caption</em> and text <em>text</em>. The about box's parent is <em>parent</em>.
|
||
|
<p> <a href="#about">about</a>() looks for a suitable icon in four locations:
|
||
|
<ol type=1>
|
||
|
<li> It prefers <a href="qwidget.html#icon">parent->icon()</a> if that exists.
|
||
|
<li> If not, it tries the top-level widget containing <em>parent</em>.
|
||
|
<li> If that fails, it tries the <a href="qapplication.html#mainWidget">main widget.</a>
|
||
|
<li> As a last resort it uses the Information icon.
|
||
|
</ol>
|
||
|
<p> The about box has a single button labelled "OK".
|
||
|
<p> <p>See also <a href="qwidget.html#icon-prop">QWidget::icon</a> and <a href="qapplication.html#mainWidget">QApplication::mainWidget</a>().
|
||
|
|
||
|
<p>Examples: <a href="qaction-application-example.html#x1137">action/application.cpp</a>, <a href="simple-application-example.html#x1555">application/application.cpp</a>, <a href="canvas-chart-example.html#x2886">chart/chartform.cpp</a>, <a href="helpviewer-example.html#x994">helpviewer/helpwindow.cpp</a>, <a href="mdi-example.html#x2036">mdi/application.cpp</a>, <a href="menu-example.html#x1874">menu/menu.cpp</a>, and <a href="themes-example.html#x330">themes/themes.cpp</a>.
|
||
|
<h3 class=fn>void <a name="aboutQt"></a>QMessageBox::aboutQt ( <a href="qwidget.html">QWidget</a> * parent, const <a href="qstring.html">QString</a> & caption = QString::null )<tt> [static]</tt>
|
||
|
</h3>
|
||
|
Displays a simple message box about Qt, with caption <em>caption</em>
|
||
|
and centered over <em>parent</em> (if <em>parent</em> is not 0). The message
|
||
|
includes the version number of Qt being used by the application.
|
||
|
<p> This is useful for inclusion in the Help menu of an application.
|
||
|
See the examples/menu/menu.cpp example.
|
||
|
<p> <a href="qapplication.html">QApplication</a> provides this functionality as a slot.
|
||
|
<p> <p>See also <a href="qapplication.html#aboutQt">QApplication::aboutQt</a>().
|
||
|
|
||
|
<p>Examples: <a href="qaction-application-example.html#x1138">action/application.cpp</a>, <a href="simple-application-example.html#x1556">application/application.cpp</a>, <a href="canvas-chart-example.html#x2887">chart/chartform.cpp</a>, <a href="helpviewer-example.html#x995">helpviewer/helpwindow.cpp</a>, <a href="menu-example.html#x1875">menu/menu.cpp</a>, <a href="themes-example.html#x331">themes/themes.cpp</a>, and <a href="trivial-nsplugin-example.html#x2736">trivial/trivial.cpp</a>.
|
||
|
<h3 class=fn>void <a name="adjustSize"></a>QMessageBox::adjustSize ()<tt> [virtual]</tt>
|
||
|
</h3>
|
||
|
Adjusts the size of the message box to fit the contents just before
|
||
|
<a href="qdialog.html#exec">QDialog::exec</a>() or <a href="qdialog.html#show">QDialog::show</a>() is called.
|
||
|
<p> This function will not be called if the message box has been explicitly
|
||
|
resized before showing it.
|
||
|
|
||
|
<p>Reimplemented from <a href="qwidget.html#adjustSize">QWidget</a>.
|
||
|
<h3 class=fn><a href="qstring.html">QString</a> <a name="buttonText"></a>QMessageBox::buttonText ( int button ) const
|
||
|
</h3>
|
||
|
Returns the text of the message box button <em>button</em>, or
|
||
|
<a href="qstring.html#QString-null">QString::null</a> if the message box does not contain the button.
|
||
|
<p> <p>See also <a href="#setButtonText">setButtonText</a>().
|
||
|
|
||
|
<h3 class=fn>int <a name="critical"></a>QMessageBox::critical ( <a href="qwidget.html">QWidget</a> * parent, const <a href="qstring.html">QString</a> & caption, const <a href="qstring.html">QString</a> & text, int button0, int button1, int button2 = 0 )<tt> [static]</tt>
|
||
|
</h3>
|
||
|
Opens a critical message box with the caption <em>caption</em> and the
|
||
|
text <em>text</em>. The dialog may have up to three buttons. Each of the
|
||
|
button parameters, <em>button0</em>, <em>button1</em> and <em>button2</em> may be
|
||
|
set to one of the following values:
|
||
|
<p> <ul>
|
||
|
<li> QMessageBox::NoButton
|
||
|
<li> QMessageBox::Ok
|
||
|
<li> QMessageBox::Cancel
|
||
|
<li> QMessageBox::Yes
|
||
|
<li> QMessageBox::No
|
||
|
<li> QMessageBox::Abort
|
||
|
<li> QMessageBox::Retry
|
||
|
<li> QMessageBox::Ignore
|
||
|
<li> QMessageBox::YesAll
|
||
|
<li> QMessageBox::NoAll
|
||
|
</ul>
|
||
|
<p> If you don't want all three buttons, set the last button, or last
|
||
|
two buttons to QMessageBox::NoButton.
|
||
|
<p> One button can be OR-ed with <tt>QMessageBox::Default</tt>, and one
|
||
|
button can be OR-ed with <tt>QMessageBox::Escape</tt>.
|
||
|
<p> Returns the identity (QMessageBox::Ok, or QMessageBox::No, etc.)
|
||
|
of the button that was clicked.
|
||
|
<p> If <em>parent</em> is 0, the message box becomes an application-global
|
||
|
modal dialog box. If <em>parent</em> is a widget, the message box
|
||
|
becomes modal relative to <em>parent</em>.
|
||
|
<p> <p>See also <a href="#information">information</a>(), <a href="#question">question</a>(), and <a href="#warning">warning</a>().
|
||
|
|
||
|
<p>Examples: <a href="archivesearch-example.html#x478">network/archivesearch/archivedialog.ui.h</a>, <a href="ftpclient-example.html#x767">network/ftpclient/ftpmainwindow.ui.h</a>, <a href="process-example.html#x96">process/process.cpp</a>, and <a href="outliner-example.html#x1917">xml/outliner/outlinetree.cpp</a>.
|
||
|
<h3 class=fn>int <a name="critical-2"></a>QMessageBox::critical ( <a href="qwidget.html">QWidget</a> * parent, const <a href="qstring.html">QString</a> & caption, const <a href="qstring.html">QString</a> & text, const <a href="qstring.html">QString</a> & button0Text = QString::null, const <a href="qstring.html">QString</a> & button1Text = QString::null, const <a href="qstring.html">QString</a> & button2Text = QString::null, int defaultButtonNumber = 0, int escapeButtonNumber = -1 )<tt> [static]</tt>
|
||
|
</h3>
|
||
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
||
|
<p> 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).
|
||
|
<p> <em>button0Text</em> is the text of the first button, and is optional.
|
||
|
If <em>button0Text</em> is not supplied, "OK" (translated) will be used.
|
||
|
<em>button1Text</em> is the text of the second button, and is optional,
|
||
|
and <em>button2Text</em> is the text of the third button, and is
|
||
|
optional. <em>defaultButtonNumber</em> (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). <em>escapeButtonNumber</em> 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.
|
||
|
<p> If <em>parent</em> is 0, the message box becomes an application-global
|
||
|
modal dialog box. If <em>parent</em> is a widget, the message box
|
||
|
becomes modal relative to <em>parent</em>.
|
||
|
<p> <p>See also <a href="#information">information</a>(), <a href="#question">question</a>(), and <a href="#warning">warning</a>().
|
||
|
|
||
|
<h3 class=fn><a href="qmessagebox.html#Icon-enum">Icon</a> <a name="icon"></a>QMessageBox::icon () const
|
||
|
</h3><p>Returns the message box's icon.
|
||
|
See the <a href="qmessagebox.html#icon-prop">"icon"</a> property for details.
|
||
|
<h3 class=fn>const <a href="qpixmap.html">QPixmap</a> * <a name="iconPixmap"></a>QMessageBox::iconPixmap () const
|
||
|
</h3><p>Returns the current icon.
|
||
|
See the <a href="qmessagebox.html#iconPixmap-prop">"iconPixmap"</a> property for details.
|
||
|
<h3 class=fn>int <a name="information"></a>QMessageBox::information ( <a href="qwidget.html">QWidget</a> * parent, const <a href="qstring.html">QString</a> & caption, const <a href="qstring.html">QString</a> & text, int button0, int button1 = 0, int button2 = 0 )<tt> [static]</tt>
|
||
|
</h3>
|
||
|
Opens an information message box with the caption <em>caption</em> and
|
||
|
the text <em>text</em>. The dialog may have up to three buttons. Each of
|
||
|
the buttons, <em>button0</em>, <em>button1</em> and <em>button2</em> may be set to
|
||
|
one of the following values:
|
||
|
<p> <ul>
|
||
|
<li> QMessageBox::NoButton
|
||
|
<li> QMessageBox::Ok
|
||
|
<li> QMessageBox::Cancel
|
||
|
<li> QMessageBox::Yes
|
||
|
<li> QMessageBox::No
|
||
|
<li> QMessageBox::Abort
|
||
|
<li> QMessageBox::Retry
|
||
|
<li> QMessageBox::Ignore
|
||
|
<li> QMessageBox::YesAll
|
||
|
<li> QMessageBox::NoAll
|
||
|
</ul>
|
||
|
<p> If you don't want all three buttons, set the last button, or last
|
||
|
two buttons to QMessageBox::NoButton.
|
||
|
<p> One button can be OR-ed with <tt>QMessageBox::Default</tt>, and one
|
||
|
button can be OR-ed with <tt>QMessageBox::Escape</tt>.
|
||
|
<p> Returns the identity (QMessageBox::Ok, or QMessageBox::No, etc.)
|
||
|
of the button that was clicked.
|
||
|
<p> If <em>parent</em> is 0, the message box becomes an application-global
|
||
|
modal dialog box. If <em>parent</em> is a widget, the message box
|
||
|
becomes modal relative to <em>parent</em>.
|
||
|
<p> <p>See also <a href="#question">question</a>(), <a href="#warning">warning</a>(), and <a href="#critical">critical</a>().
|
||
|
|
||
|
<p>Examples: <a href="qaction-application-example.html#x1139">action/application.cpp</a>, <a href="simple-application-example.html#x1557">application/application.cpp</a>, <a href="dirview-example.html#x1695">dirview/dirview.cpp</a>, <a href="fileiconview-example.html#x859">fileiconview/qfileiconview.cpp</a>, <a href="picture-example.html#x110">picture/picture.cpp</a>, <a href="qwerty-example.html#x373">qwerty/qwerty.cpp</a>, and <a href="qaxserver-example-simple.html#x2524">simple/main.cpp</a>.
|
||
|
<h3 class=fn>int <a name="information-2"></a>QMessageBox::information ( <a href="qwidget.html">QWidget</a> * parent, const <a href="qstring.html">QString</a> & caption, const <a href="qstring.html">QString</a> & text, const <a href="qstring.html">QString</a> & button0Text = QString::null, const <a href="qstring.html">QString</a> & button1Text = QString::null, const <a href="qstring.html">QString</a> & button2Text = QString::null, int defaultButtonNumber = 0, int escapeButtonNumber = -1 )<tt> [static]</tt>
|
||
|
</h3>
|
||
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
||
|
<p> Displays an information message box with caption <em>caption</em>, text
|
||
|
<em>text</em> and one, two or three buttons. Returns the index of the
|
||
|
button that was clicked (0, 1 or 2).
|
||
|
<p> <em>button0Text</em> is the text of the first button, and is optional.
|
||
|
If <em>button0Text</em> is not supplied, "OK" (translated) will be used.
|
||
|
<em>button1Text</em> is the text of the second button, and is optional.
|
||
|
<em>button2Text</em> is the text of the third button, and is optional.
|
||
|
<em>defaultButtonNumber</em> (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). <em>escapeButtonNumber</em> 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.
|
||
|
<p> If <em>parent</em> is 0, the message box becomes an application-global
|
||
|
modal dialog box. If <em>parent</em> is a widget, the message box
|
||
|
becomes modal relative to <em>parent</em>.
|
||
|
<p> 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.
|
||
|
<p> <p>See also <a href="#question">question</a>(), <a href="#warning">warning</a>(), and <a href="#critical">critical</a>().
|
||
|
|
||
|
<h3 class=fn>int <a name="message"></a>QMessageBox::message ( const <a href="qstring.html">QString</a> & caption, const <a href="qstring.html">QString</a> & text, const <a href="qstring.html">QString</a> & buttonText = QString::null, <a href="qwidget.html">QWidget</a> * parent = 0, const char * = 0 )<tt> [static]</tt>
|
||
|
</h3>
|
||
|
<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
||
|
<p> Opens a modal message box directly using the specified parameters.
|
||
|
<p> Please use <a href="#information">information</a>(), <a href="#warning">warning</a>(), <a href="#question">question</a>(), or <a href="#critical">critical</a>() instead.
|
||
|
|
||
|
<p>Example: <a href="grapher-nsplugin-example.html#x2750">grapher/grapher.cpp</a>.
|
||
|
<h3 class=fn>bool <a name="query"></a>QMessageBox::query ( const <a href="qstring.html">QString</a> & caption, const <a href="qstring.html">QString</a> & text, const <a href="qstring.html">QString</a> & yesButtonText = QString::null, const <a href="qstring.html">QString</a> & noButtonText = QString::null, <a href="qwidget.html">QWidget</a> * parent = 0, const char * = 0 )<tt> [static]</tt>
|
||
|
</h3>
|
||
|
<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
||
|
<p> Queries the user using a modal message box with two buttons.
|
||
|
Note that <em>caption</em> is not always shown, it depends on the window manager.
|
||
|
<p> Please use <a href="#information">information</a>(), <a href="#question">question</a>(), <a href="#warning">warning</a>(), or <a href="#critical">critical</a>() instead.
|
||
|
|
||
|
<h3 class=fn>int <a name="question"></a>QMessageBox::question ( <a href="qwidget.html">QWidget</a> * parent, const <a href="qstring.html">QString</a> & caption, const <a href="qstring.html">QString</a> & text, int button0, int button1 = 0, int button2 = 0 )<tt> [static]</tt>
|
||
|
</h3>
|
||
|
Opens a question message box with the caption <em>caption</em> and the
|
||
|
text <em>text</em>. The dialog may have up to three buttons. Each of the
|
||
|
buttons, <em>button0</em>, <em>button1</em> and <em>button2</em> may be set to one
|
||
|
of the following values:
|
||
|
<p> <ul>
|
||
|
<li> QMessageBox::NoButton
|
||
|
<li> QMessageBox::Ok
|
||
|
<li> QMessageBox::Cancel
|
||
|
<li> QMessageBox::Yes
|
||
|
<li> QMessageBox::No
|
||
|
<li> QMessageBox::Abort
|
||
|
<li> QMessageBox::Retry
|
||
|
<li> QMessageBox::Ignore
|
||
|
<li> QMessageBox::YesAll
|
||
|
<li> QMessageBox::NoAll
|
||
|
</ul>
|
||
|
<p> If you don't want all three buttons, set the last button, or last
|
||
|
two buttons to QMessageBox::NoButton.
|
||
|
<p> One button can be OR-ed with <tt>QMessageBox::Default</tt>, and one
|
||
|
button can be OR-ed with <tt>QMessageBox::Escape</tt>.
|
||
|
<p> Returns the identity (QMessageBox::Yes, or QMessageBox::No, etc.)
|
||
|
of the button that was clicked.
|
||
|
<p> If <em>parent</em> is 0, the message box becomes an application-global
|
||
|
modal dialog box. If <em>parent</em> is a widget, the message box
|
||
|
becomes modal relative to <em>parent</em>.
|
||
|
<p> <p>See also <a href="#information">information</a>(), <a href="#warning">warning</a>(), and <a href="#critical">critical</a>().
|
||
|
|
||
|
<h3 class=fn>int <a name="question-2"></a>QMessageBox::question ( <a href="qwidget.html">QWidget</a> * parent, const <a href="qstring.html">QString</a> & caption, const <a href="qstring.html">QString</a> & text, const <a href="qstring.html">QString</a> & button0Text = QString::null, const <a href="qstring.html">QString</a> & button1Text = QString::null, const <a href="qstring.html">QString</a> & button2Text = QString::null, int defaultButtonNumber = 0, int escapeButtonNumber = -1 )<tt> [static]</tt>
|
||
|
</h3>
|
||
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
||
|
<p> Displays a question message box with caption <em>caption</em>, text <em>text</em> and one, two or three buttons. Returns the index of the
|
||
|
button that was clicked (0, 1 or 2).
|
||
|
<p> <em>button0Text</em> is the text of the first button, and is optional.
|
||
|
If <em>button0Text</em> is not supplied, "OK" (translated) will be used.
|
||
|
<em>button1Text</em> is the text of the second button, and is optional.
|
||
|
<em>button2Text</em> is the text of the third button, and is optional.
|
||
|
<em>defaultButtonNumber</em> (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). <em>escapeButtonNumber</em> 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.
|
||
|
<p> If <em>parent</em> is 0, the message box becomes an application-global
|
||
|
modal dialog box. If <em>parent</em> is a widget, the message box
|
||
|
becomes modal relative to <em>parent</em>.
|
||
|
<p> 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.
|
||
|
<p> <p>See also <a href="#information">information</a>(), <a href="#warning">warning</a>(), and <a href="#critical">critical</a>().
|
||
|
|
||
|
<h3 class=fn>void <a name="setButtonText"></a>QMessageBox::setButtonText ( int button, const <a href="qstring.html">QString</a> & text )
|
||
|
</h3>
|
||
|
Sets the text of the message box button <em>button</em> to <em>text</em>.
|
||
|
Setting the text of a button that is not in the message box is
|
||
|
silently ignored.
|
||
|
<p> <p>See also <a href="#buttonText">buttonText</a>().
|
||
|
|
||
|
<h3 class=fn>void <a name="setIcon"></a>QMessageBox::setIcon ( <a href="qmessagebox.html#Icon-enum">Icon</a> )
|
||
|
</h3><p>Sets the message box's icon.
|
||
|
See the <a href="qmessagebox.html#icon-prop">"icon"</a> property for details.
|
||
|
<h3 class=fn>void <a name="setIconPixmap"></a>QMessageBox::setIconPixmap ( const <a href="qpixmap.html">QPixmap</a> & )
|
||
|
</h3><p>Sets the current icon.
|
||
|
See the <a href="qmessagebox.html#iconPixmap-prop">"iconPixmap"</a> property for details.
|
||
|
<h3 class=fn>void <a name="setText"></a>QMessageBox::setText ( const <a href="qstring.html">QString</a> & )
|
||
|
</h3><p>Sets the message box text to be displayed.
|
||
|
See the <a href="qmessagebox.html#text-prop">"text"</a> property for details.
|
||
|
<h3 class=fn>void <a name="setTextFormat"></a>QMessageBox::setTextFormat ( <a href="qt.html#TextFormat-enum">TextFormat</a> )
|
||
|
</h3><p>Sets the format of the text displayed by the message box.
|
||
|
See the <a href="qmessagebox.html#textFormat-prop">"textFormat"</a> property for details.
|
||
|
<h3 class=fn><a href="qpixmap.html">QPixmap</a> <a name="standardIcon"></a>QMessageBox::standardIcon ( <a href="qmessagebox.html#Icon-enum">Icon</a> icon )<tt> [static]</tt>
|
||
|
</h3>
|
||
|
Returns the pixmap used for a standard icon. This allows the
|
||
|
pixmaps to be used in more complex message boxes. <em>icon</em>
|
||
|
specifies the required icon, e.g. QMessageBox::Question,
|
||
|
QMessageBox::Information, QMessageBox::Warning or
|
||
|
QMessageBox::Critical.
|
||
|
|
||
|
<h3 class=fn><a href="qpixmap.html">QPixmap</a> <a name="standardIcon-2"></a>QMessageBox::standardIcon ( <a href="qmessagebox.html#Icon-enum">Icon</a> icon, <a href="qt.html#GUIStyle-enum">GUIStyle</a> style )<tt> [static]</tt>
|
||
|
</h3>
|
||
|
<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
||
|
<p> Returns the pixmap used for a standard icon. This
|
||
|
allows the pixmaps to be used in more complex message boxes.
|
||
|
<em>icon</em> specifies the required icon, e.g. QMessageBox::Information,
|
||
|
QMessageBox::Warning or QMessageBox::Critical.
|
||
|
<p> <em>style</em> is unused.
|
||
|
|
||
|
<h3 class=fn><a href="qstring.html">QString</a> <a name="text"></a>QMessageBox::text () const
|
||
|
</h3><p>Returns the message box text to be displayed.
|
||
|
See the <a href="qmessagebox.html#text-prop">"text"</a> property for details.
|
||
|
<h3 class=fn><a href="qt.html#TextFormat-enum">TextFormat</a> <a name="textFormat"></a>QMessageBox::textFormat () const
|
||
|
</h3><p>Returns the format of the text displayed by the message box.
|
||
|
See the <a href="qmessagebox.html#textFormat-prop">"textFormat"</a> property for details.
|
||
|
<h3 class=fn>int <a name="warning"></a>QMessageBox::warning ( <a href="qwidget.html">QWidget</a> * parent, const <a href="qstring.html">QString</a> & caption, const <a href="qstring.html">QString</a> & text, int button0, int button1, int button2 = 0 )<tt> [static]</tt>
|
||
|
</h3>
|
||
|
Opens a warning message box with the caption <em>caption</em> and the
|
||
|
text <em>text</em>. The dialog may have up to three buttons. Each of the
|
||
|
button parameters, <em>button0</em>, <em>button1</em> and <em>button2</em> may be
|
||
|
set to one of the following values:
|
||
|
<p> <ul>
|
||
|
<li> QMessageBox::NoButton
|
||
|
<li> QMessageBox::Ok
|
||
|
<li> QMessageBox::Cancel
|
||
|
<li> QMessageBox::Yes
|
||
|
<li> QMessageBox::No
|
||
|
<li> QMessageBox::Abort
|
||
|
<li> QMessageBox::Retry
|
||
|
<li> QMessageBox::Ignore
|
||
|
<li> QMessageBox::YesAll
|
||
|
<li> QMessageBox::NoAll
|
||
|
</ul>
|
||
|
<p> If you don't want all three buttons, set the last button, or last
|
||
|
two buttons to QMessageBox::NoButton.
|
||
|
<p> One button can be OR-ed with <tt>QMessageBox::Default</tt>, and one
|
||
|
button can be OR-ed with <tt>QMessageBox::Escape</tt>.
|
||
|
<p> Returns the identity (QMessageBox::Ok, or QMessageBox::No, etc.)
|
||
|
of the button that was clicked.
|
||
|
<p> If <em>parent</em> is 0, the message box becomes an application-global
|
||
|
modal dialog box. If <em>parent</em> is a widget, the message box
|
||
|
becomes modal relative to <em>parent</em>.
|
||
|
<p> <p>See also <a href="#information">information</a>(), <a href="#question">question</a>(), and <a href="#critical">critical</a>().
|
||
|
|
||
|
<p>Examples: <a href="tutorial2-05.html#x2566">chart/chartform.cpp</a>, <a href="i18n-example.html#x1940">i18n/main.cpp</a>, <a href="mail-example.html#x708">network/mail/smtp.cpp</a>, <a href="qwerty-example.html#x374">qwerty/qwerty.cpp</a>, <a href="showimg-example.html#x1333">showimg/showimg.cpp</a>, and <a href="sound-example.html#x2812">sound/sound.cpp</a>.
|
||
|
<h3 class=fn>int <a name="warning-2"></a>QMessageBox::warning ( <a href="qwidget.html">QWidget</a> * parent, const <a href="qstring.html">QString</a> & caption, const <a href="qstring.html">QString</a> & text, const <a href="qstring.html">QString</a> & button0Text = QString::null, const <a href="qstring.html">QString</a> & button1Text = QString::null, const <a href="qstring.html">QString</a> & button2Text = QString::null, int defaultButtonNumber = 0, int escapeButtonNumber = -1 )<tt> [static]</tt>
|
||
|
</h3>
|
||
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
||
|
<p> 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).
|
||
|
<p> <em>button0Text</em> is the text of the first button, and is optional.
|
||
|
If <em>button0Text</em> is not supplied, "OK" (translated) will be used.
|
||
|
<em>button1Text</em> is the text of the second button, and is optional,
|
||
|
and <em>button2Text</em> is the text of the third button, and is
|
||
|
optional. <em>defaultButtonNumber</em> (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). <em>escapeButtonNumber</em> 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.
|
||
|
<p> If <em>parent</em> is 0, the message box becomes an application-global
|
||
|
modal dialog box. If <em>parent</em> is a widget, the message box
|
||
|
becomes modal relative to <em>parent</em>.
|
||
|
<p> 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.
|
||
|
<p> <p>See also <a href="#information">information</a>(), <a href="#question">question</a>(), and <a href="#critical">critical</a>().
|
||
|
|
||
|
<hr><h2>Property Documentation</h2>
|
||
|
<h3 class=fn><a href="qmessagebox.html#Icon-enum">Icon</a> <a name="icon-prop"></a>icon</h3>
|
||
|
<p>This property holds the message box's icon.
|
||
|
<p>The icon of the message box can be one of the following predefined
|
||
|
icons:
|
||
|
<ul>
|
||
|
<li> QMessageBox::NoIcon
|
||
|
<li> QMessageBox::Question
|
||
|
<li> QMessageBox::Information
|
||
|
<li> QMessageBox::Warning
|
||
|
<li> QMessageBox::Critical
|
||
|
</ul>
|
||
|
<p> The actual pixmap used for displaying the icon depends on the
|
||
|
current <a href="qwidget.html#style">GUI style</a>. You can also set
|
||
|
a custom pixmap icon using the <a href="#iconPixmap-prop">QMessageBox::iconPixmap</a>
|
||
|
property. The default icon is QMessageBox::NoIcon.
|
||
|
<p> <p>See also <a href="#iconPixmap-prop">iconPixmap</a>.
|
||
|
|
||
|
<p>Set this property's value with <a href="#setIcon">setIcon</a>() and get this property's value with <a href="#icon">icon</a>().
|
||
|
<h3 class=fn><a href="qpixmap.html">QPixmap</a> <a name="iconPixmap-prop"></a>iconPixmap</h3>
|
||
|
<p>This property holds the current icon.
|
||
|
<p>The icon currently used by the message box. Note that it's often
|
||
|
hard to draw one pixmap that looks appropriate in both <a href="motif-extension.html#Motif">Motif</a> and
|
||
|
Windows GUI styles; you may want to draw two pixmaps.
|
||
|
<p> <p>See also <a href="#icon-prop">icon</a>.
|
||
|
|
||
|
<p>Set this property's value with <a href="#setIconPixmap">setIconPixmap</a>() and get this property's value with <a href="#iconPixmap">iconPixmap</a>().
|
||
|
<h3 class=fn><a href="qstring.html">QString</a> <a name="text-prop"></a>text</h3>
|
||
|
<p>This property holds the message box text to be displayed.
|
||
|
<p>The text will be interpreted either as a plain text or as rich
|
||
|
text, depending on the text format setting (<a href="#textFormat-prop">QMessageBox::textFormat</a>). The default setting is <a href="qt.html#TextFormat-enum">AutoText</a>, i.e.
|
||
|
the message box will try to auto-detect the format of the text.
|
||
|
<p> The default value of this property is <a href="qstring.html#QString-null">QString::null</a>.
|
||
|
<p> <p>See also <a href="#textFormat-prop">textFormat</a>.
|
||
|
|
||
|
<p>Set this property's value with <a href="#setText">setText</a>() and get this property's value with <a href="#text">text</a>().
|
||
|
<h3 class=fn><a href="qt.html#TextFormat-enum">TextFormat</a> <a name="textFormat-prop"></a>textFormat</h3>
|
||
|
<p>This property holds the format of the text displayed by the message box.
|
||
|
<p>The current text format used by the message box. See the <a href="qt.html#TextFormat-enum">Qt::TextFormat</a> enum for an explanation of the possible options.
|
||
|
<p> The default format is <a href="qt.html#TextFormat-enum">AutoText</a>.
|
||
|
<p> <p>See also <a href="#text-prop">text</a>.
|
||
|
|
||
|
<p>Set this property's value with <a href="#setTextFormat">setTextFormat</a>() and get this property's value with <a href="#textFormat">textFormat</a>().
|
||
|
<!-- eof -->
|
||
|
<hr><p>
|
||
|
This file is part of the <a href="index.html">Qt toolkit</a>.
|
||
|
Copyright © 1995-2007
|
||
|
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
||
|
<table width=100% cellspacing=0 border=0><tr>
|
||
|
<td>Copyright © 2007
|
||
|
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
||
|
<td align=right><div align=right>Qt 3.3.8</div>
|
||
|
</table></div></address></body>
|
||
|
</html>
|