📄 qmessagebox.html
字号:
<p>实例:<a href="ftpclient-example.html#x664">network/ftpclient/ftpmainwindow.cpp</a>、<a href="process-example.html#x64">process/process.cpp</a>和<a href="outliner-example.html#x1906">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> [静态]</tt>
</h3>
这是一个重载成员函数,提供了方便。它的行为基本上和上面的函数相同。
<p> 显示一个标题为<em>caption</em>、文本为<em>text</em>并且按钮分别为1、2、3的严重消息对话框。返回被点击的按钮的数字(0、1或2)。
<p> <em>button0Text</em>为第一个按钮的文本并且它是可选的。如果<em>button0Text</em>没有被提供,“OK”(被翻译的)将被使用。<em>button1Text</em>为第二个按钮的文本并且它是可选的并且<em>button2Text</em>为第三个按钮的文本并且它是可选的。<em>defaultButtonNumber</em>(0、1或2)是默认按钮的索引,按下Return或者Enter和点击这个默认按钮是相同的。它默认为0(第一个按钮)。<em>escapeButtonNumber</em>是Escape按钮的索引,按下Escape和点击这个按钮是相同的。它默认为-1(就是按下Escape什么也不做),提供0、1或2使按下Escape等同于按下对应的按钮。
<p> 如果<em>parent</em>为0,消息框变为应用程序全局的模式对话框。如果<em>parent</em>为一个窗口部件,消息框变为相对于<em>parent</em>的模式对话框。
<p> <p>也可以参考<a href="#information">information</a>()和<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>返回消息框的图标。详细情况请参考<a href="qmessagebox.html#icon-prop">“icon”</a>属性。
<h3 class=fn>const <a href="qpixmap.html">QPixmap</a> * <a name="iconPixmap"></a>QMessageBox::iconPixmap () const
</h3>
<p>返回当前图标。详细情况请参考<a href="qmessagebox.html#iconPixmap-prop">“iconPixmap”</a>属性。
<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> [静态]</tt>
</h3>
打开一个标题为<em>caption</em>并且文本为<em>text</em>的信息消息框。这个对话框最多有三个按钮。每个按钮参数<em>button0</em>、<em>button1</em>和<em>button2</em>被设置为下列各值之一:
<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
</ul>
<p> 如果你不想要三个按钮,设置最后一个按钮或者最后两个按钮为QMessageBox::NoButton。
<p> 返回被点击的按钮地标识(QMessageBox::Ok或QMessageBox::No等等)。
<p> 如果<em>parent</em>为0,消息框变为应用程序全局的模式对话框。如果<em>parent</em>为一个窗口部件,消息框变为相对于<em>parent</em>的模式对话框。
<p> <p>也可以参考<a href="#warning">warning</a>()和<a href="#critical">critical</a>()。
<p>实例:<a href="qaction-application-example.html#x1076">action/application.cpp</a>、<a href="simple-application-example.html#x1521">application/application.cpp</a>、<a href="canvas-chart-example.html#x2605">chart/chartform.cpp</a>、<a href="dirview-example.html#x1735">dirview/dirview.cpp</a>、<a href="fileiconview-example.html#x855">fileiconview/qfileiconview.cpp</a>、<a href="picture-example.html#x78">picture/picture.cpp</a>和<a href="qwerty-example.html#x371">qwerty/qwerty.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> [静态]</tt>
</h3>
这是一个重载成员函数,提供了方便。它的行为基本上和上面的函数相同。
<p> 显示一个标题为<em>caption</em>、文本为<em>text</em>并且按钮分别为1、2、3的信息消息对话框。返回被点击的按钮的数字(0、1或2)。
<p> <em>button0Text</em>为第一个按钮的文本并且它是可选的。如果<em>button0Text</em>没有被提供,“OK”(被翻译的)将被使用。<em>button1Text</em>为第二个按钮的文本并且它是可选的并且<em>button2Text</em>为第三个按钮的文本并且它是可选的。<em>defaultButtonNumber</em>(0、1或2)是默认按钮的索引,按下Return或者Enter和点击这个默认按钮是相同的。它默认为0(第一个按钮)。<em>escapeButtonNumber</em>是Escape按钮的索引,按下Escape和点击这个按钮是相同的。它默认为-1(就是按下Escape什么也不做),提供0、1或2使按下Escape等同于按下对应的按钮。
<p> 如果<em>parent</em>为0,消息框变为应用程序全局的模式对话框。如果<em>parent</em>为一个窗口部件,消息框变为相对于<em>parent</em>的模式对话框。
<p> <p>也可以参考<a href="#warning">warning</a>()和<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> [静态]</tt>
</h3>
<p> <b>这个函数是废弃的。</b>它的提供只是为了保证旧代码能够工作。我们强烈建议在新代码中不要使用它。
<p> 使用特定参数直接打开模式消息框。
<p> 请使用<a href="#information">information</a>()、<a href="#warning">warning</a>()或<a href="#critical">critical</a>()来替代。
<p>实例:<a href="grapher-nsplugin-example.html#x2758">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> [静态]</tt>
</h3>
<p> <b>这个函数是废弃的。</b>它的提供只是为了保证旧代码能够工作。我们强烈建议在新代码中不要使用它。
<p> 使用有两个按钮的模式消息框询问用户。注意<em>caption</em>不总是被显示,它依赖于窗口管理器。
<p> 请使用<a href="#information">information</a>()、<a href="#warning">warning</a>()或<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>
设置消息框按钮<em>button</em>的文本为<em>text</em>。设置一个没有在消息框中出现的按钮的文本会被默默地忽略。
<p> <p>也可以参考<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>设置消息框的图标。详细情况请参考<a href="qmessagebox.html#icon-prop">“icon”</a>属性。
<h3 class=fn>void <a name="setIconPixmap"></a>QMessageBox::setIconPixmap ( const <a href="qpixmap.html">QPixmap</a> & )
</h3>
<p>设置当前图标。详细情况请参考<a href="qmessagebox.html#iconPixmap-prop">“iconPixmap”</a>属性。
<h3 class=fn>void <a name="setText"></a>QMessageBox::setText ( const <a href="qstring.html">QString</a> & )
</h3>
<p>设置被显示的消息框文本。详细情况请参考<a href="qmessagebox.html#text-prop">“text”</a>属性。
<h3 class=fn>void <a name="setTextFormat"></a>QMessageBox::setTextFormat ( <a href="qt.html#TextFormat-enum">TextFormat</a> )
</h3>
<p>设置消息框中被显示的文本的格式。详细情况请参考<a href="qmessagebox.html#textFormat-prop">“textFormat”</a>属性。
<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> [静态]</tt>
</h3>
返回标准图标使用的像素映射。这允许这些像素映射用于更复杂的消息框。<em>icon</em>指定了所需图标,例如QMessageBox::Information、QMessageBox::Warning或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> [静态]</tt>
</h3>
<p> <b>这个函数是废弃的。</b>它的提供只是为了保证旧代码能够工作。我们强烈建议在新代码中不要使用它。
<p> 返回标准图标使用的像素映射。这允许这些像素映射用于更复杂的消息框。<em>icon</em>指定了所需图标,例如QMessageBox::Information、QMessageBox::Warning或QMessageBox::Critical。
<p> <em>style</em>不被使用。
<h3 class=fn><a href="qstring.html">QString</a> <a name="text"></a>QMessageBox::text () const
</h3>
<p>返回被显示的消息框文本。详细情况请参考<a href="qmessagebox.html#text-prop">“text”</a>属性。
<h3 class=fn><a href="qt.html#TextFormat-enum">TextFormat</a> <a name="textFormat"></a>QMessageBox::textFormat () const
</h3>
<p>返回消息框中被显示的文本的格式。详细情况请参考<a href="qmessagebox.html#textFormat-prop">“textFormat”</a>属性。
<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> [静态]</tt>
</h3>
打开一个标题为<em>caption</em>并且文本为<em>text</em>的警告消息框。这个对话框最多有三个按钮。每个按钮参数<em>button0</em>、<em>button1</em>和<em>button2</em>被设置为下列各值之一:
<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
</ul>
<p> 如果你不想要三个按钮,设置最后一个按钮或者最后两个按钮为QMessageBox::NoButton。
<p> 返回被点击的按钮地标识(QMessageBox::Ok或QMessageBox::No等等)。
<p> 如果<em>parent</em>为0,消息框变为应用程序全局的模式对话框。如果<em>parent</em>为一个窗口部件,消息框变为相对于<em>parent</em>的模式对话框。
<p> <p>也可以参考<a href="#information">information</a>()和<a href="#critical">critical</a>()。
<p>实例:<a href="tutorial2-05.html#x2471">chart/chartform.cpp</a>、<a href="i18n-example.html#x1929">i18n/main.cpp</a>、<a href="mail-example.html#x754">network/mail/smtp.cpp</a>、<a href="qwerty-example.html#x372">qwerty/qwerty.cpp</a>、<a href="showimg-example.html#x1271">showimg/showimg.cpp</a>和<a href="sound-example.html#x2659">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> [静态]</tt>
</h3>
这是一个重载成员函数,提供了方便。它的行为基本上和上面的函数相同。
<p> 显示一个标题为<em>caption</em>、文本为<em>text</em>并且按钮分别为1、2、3的警告消息对话框。返回被点击的按钮的数字(0、1或2)。
<p> <em>button0Text</em>为第一个按钮的文本并且它是可选的。如果<em>button0Text</em>没有被提供,“OK”(被翻译的)将被使用。<em>button1Text</em>为第二个按钮的文本并且它是可选的并且<em>button2Text</em>为第三个按钮的文本并且它是可选的。<em>defaultButtonNumber</em>(0、1或2)是默认按钮的索引,按下Return或者Enter和点击这个默认按钮是相同的。它默认为0(第一个按钮)。<em>escapeButtonNumber</em>是Escape按钮的索引,按下Escape和点击这个按钮是相同的。它默认为-1(就是按下Escape什么也不做),提供0、1或2使按下Escape等同于按下对应的按钮。
<p> 如果<em>parent</em>为0,消息框变为应用程序全局的模式对话框。如果<em>parent</em>为一个窗口部件,消息框变为相对于<em>parent</em>的模式对话框。
<p> <p>也可以参考<a href="#information">information</a>()和<a href="#critical">critical</a>()。
<hr><h2>属性文档</h2>
<h3 class=fn><a href="qmessagebox.html#Icon-enum">Icon</a> <a name="icon-prop"></a>icon</h3>
<p>这个属性保存的是消息框的图标。
<p>消息框的图标可以是如下预定义图标的一种:
<ul>
<li> QMessageBox::NoIcon
<li> QMessageBox::Information
<li> QMessageBox::Warning
<li> QMessageBox::Critical
</ul>
<p> 用于显示图标的实际像素映射依赖于当前<a href="qwidget.html#style">图形用户界面风格</a>。你也可以使用<a href="#iconPixmap-prop">QMessageBox::iconPixmap</a>属性来设置自定义像素映射。默认图标为QMessageBox::NoIcon。
<p> <p>也可以参考<a href="#iconPixmap-prop">iconPixmap</a>。
<p>通过<a href="#setIcon">setIcon</a>()设置属性值并且通过<a href="#icon">icon</a>()来获得属性值。
<h3 class=fn><a href="qpixmap.html">QPixmap</a> <a name="iconPixmap-prop"></a>iconPixmap</h3>
<p>这个属性保存的是当前图标。
<p>这个图标正在被这个消息框使用。注意很难绘制一个在Motif和Windows风格中看起来比较一致的像素映射,你也许需要绘制两个像素映射。
<p> <p>也可以参考<a href="#icon-prop">icon</a>。
<p>通过<a href="#setIconPixmap">setIconPixmap</a>()设置属性值并且通过<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>这个文本将被解释为一般文本或者多信息文本,根据文本格式设置(<a href="#textFormat-prop">QMessageBox::textFormat</a>)。默认设置为<a href="qt.html#TextFormat-enum">AutoText</a>,也就是说消息框将会试图自动检测文本格式。
<p> 这个属性的默认设置是<a href="qstring.html#QString-null">QString::null</a>。
<p> <p>也可以参考<a href="#textFormat-prop">textFormat</a>。
<p>通过<a href="#setText">setText</a>()设置属性值并且通过<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>这是当前被消息框使用的文本格式。对于可能选项的解释请参考<a href="qt.html#TextFormat-enum">Qt::TextFormat</a>枚举变量。
<p> 默认设置是<a href="qt.html#TextFormat-enum">AutoText</a>。
<p> <p>也可以参考<a href="#text-prop">text</a>。
<p>通过<a href="#setTextFormat">setTextFormat</a>()设置属性值并且通过<a href="#textFormat">textFormat</a>()来获得属性值。
<!-- eof -->
<hr><p>
这个文件是<a href="index.html">Qt工具包</a>一部分。
版权所有 © 1995-2002
<a href="http://www.trolltech.com/">Trolltech</a>。保留所有权利。
<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright © 2002
<a href="http://www.trolltech.com">Trolltech</a>
<td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td><a href="zh_CN.html">译者:Cavendish</a>
<td align=right><div align=right>Qt 3.0.5版</div>
</table></div></address></body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -