Obsolete Members for QMessageBox
类QMessageBox 的以下成员已被弃用。提供这些成员是为了保持旧源代码的正常运行。我们强烈建议不要在新代码中使用它们。
公共类型
(deprecated) | Button |
公共函数
(deprecated) | QMessageBox(const QString &title, const QString &text, QMessageBox::Icon icon, int button0, int button1, int button2, QWidget *parent = nullptr, Qt::WindowFlags f = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint) |
(deprecated in 6.2) QString | buttonText(int button) const |
(deprecated in 6.2) void | setButtonText(int button, const QString &text) |
静态公共成员
(deprecated in 6.2) int | critical(QWidget *parent, const QString &title, const QString &text, int button0, int button1, int button2 = 0) |
(deprecated in 6.2) int | critical(QWidget *parent, const QString &title, const QString &text, const QString &button0Text, const QString &button1Text = QString(), const QString &button2Text = QString(), int defaultButtonNumber = 0, int escapeButtonNumber = -1) |
(deprecated in 6.2) int | information(QWidget *parent, const QString &title, const QString &text, int button0, int button1 = 0, int button2 = 0) |
(deprecated in 6.2) int | information(QWidget *parent, const QString &title, const QString &text, const QString &button0Text, const QString &button1Text = QString(), const QString &button2Text = QString(), int defaultButtonNumber = 0, int escapeButtonNumber = -1) |
(deprecated in 6.2) int | question(QWidget *parent, const QString &title, const QString &text, int button0, int button1 = 0, int button2 = 0) |
(deprecated in 6.2) int | question(QWidget *parent, const QString &title, const QString &text, const QString &button0Text, const QString &button1Text = QString(), const QString &button2Text = QString(), int defaultButtonNumber = 0, int escapeButtonNumber = -1) |
(deprecated in 6.2) QPixmap | standardIcon(QMessageBox::Icon icon) |
(deprecated in 6.2) int | warning(QWidget *parent, const QString &title, const QString &text, int button0, int button1, int button2 = 0) |
(deprecated in 6.2) int | warning(QWidget *parent, const QString &title, const QString &text, const QString &button0Text, const QString &button1Text = QString(), const QString &button2Text = QString(), int defaultButtonNumber = 0, int escapeButtonNumber = -1) |
成员类型文档
[deprecated]
QMessageBox::Button
该类型定义已被弃用。我们强烈建议不要在新代码中使用它。
请使用QMessageBox::StandardButton 。
成员函数文档
[deprecated]
QMessageBox::QMessageBox(const QString &title, const QString &text, QMessageBox::Icon icon, int button0, int button1, int button2, QWidget *parent = nullptr, Qt::WindowFlags f = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint)
该函数已被弃用。我们强烈建议不要在新代码中使用它。
构造一个包含title 、text 、icon 和最多三个按钮的消息框。
icon 必须是以下内容之一:
- QMessageBox::NoIcon
- QMessageBox::Question
- QMessageBox::Information
- QMessageBox::Warning
- QMessageBox::Critical
每个按钮(button0 、button1 和button2 )可以有以下值之一:
- QMessageBox::NoButton
- QMessageBox::Ok
- QMessageBox::Cancel
- QMessageBox::Yes
- QMessageBox::No
- QMessageBox::Abort
- QMessageBox::Retry
- QMessageBox::Ignore
- QMessageBox::YesAll
- QMessageBox::NoAll
如果要在消息框中设置少于三个按钮,请在后面的参数中使用QMessageBox::NoButton 。如果您没有指定任何按钮,QMessageBox 将提供一个 "确定 "按钮。
其中一个按钮可以与QMessageBox::Default 标志进行 OR 编辑,使其成为默认按钮(按回车键时点击)。
其中一个按钮可与QMessageBox::Escape 标志进行 OR 编辑,使其成为取消或关闭按钮(按下Esc 时单击)。
QMessageBox mb("Application Name", "Hardware failure.\n\nDisk error detected\nDo you want to stop?", QMessageBox::Question, QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape, QMessageBox::NoButton); if (mb.exec() == QMessageBox::No) { // try again
消息框是application modal 对话框。
parent 和f 参数传递给QDialog 构造函数。
另请参阅 setWindowTitle()、setText() 和setIcon()。
[deprecated in 6.2]
QString QMessageBox::buttonText(int button) const
自 6.2 版起,该函数已被弃用。我们强烈建议不要在新代码中使用该函数。
返回消息框按钮button 的文本,如果消息框不包含按钮,则返回空字符串。
请使用button() 和QPushButton::text() 代替。
另请参见 setButtonText()。
[static, deprecated in 6.2]
int QMessageBox::critical(QWidget *parent, const QString &title, const QString &text, int button0, int button1, int button2 = 0)
自 6.2 版起,该函数已被弃用。我们强烈建议不要在新代码中使用该函数。
请使用StandardButtons 的重载函数。
使用给定的title 和text 打开一个关键信息框。对话框最多可以有三个按钮。每个按钮参数button0 、button1 和button2 都可以设置为以下值之一:
- QMessageBox::NoButton
- QMessageBox::Ok
- QMessageBox::Cancel
- QMessageBox::Yes
- QMessageBox::No
- QMessageBox::Abort
- QMessageBox::Retry
- QMessageBox::Ignore
- QMessageBox::YesAll
- QMessageBox::NoAll
如果不需要全部三个按钮,可将最后一个按钮或最后两个按钮设置为QMessageBox::NoButton 。
一个按钮可以与QMessageBox::Default OR 结 合,一个按钮可以与QMessageBox::Escape OR 结合。
返回被点击按钮的标识(QMessageBox::Ok 或QMessageBox::No 等)。
消息框是application modal 对话框。
警告: 请勿在执行对话框期间删除parent 。如果要删除,应使用QMessageBox 构造函数自行创建对话框。
另请参阅 information()、question() 和warning()。
[static, deprecated in 6.2]
int QMessageBox::critical(QWidget *parent, const QString &title, const QString &text, const QString &button0Text, const QString &button1Text = QString(), const QString &button2Text = QString(), int defaultButtonNumber = 0, int escapeButtonNumber = -1)
自 6.2 版起,该函数已被弃用。我们强烈建议不要在新代码中使用该函数。
请使用重载函数StandardButtons 。
这是一个重载函数。
显示一个关键错误消息框,其中包含给定的title 和text 以及一个、两个或三个按钮。返回被点击按钮的编号(0、1 或 2)。
button0Text 是第一个按钮的文本,为可选项。 是第二个按钮的文本,可选; 是第三个按钮的文本,可选。 (0、1 或 2)是默认按钮的索引;按 Return 或 Enter 与单击默认按钮相同。它的默认值为 0(第一个按钮)。 是 Escape 按钮的索引;按下 Escape 与单击该按钮相同。默认值为-1;输入 0、1 或 2 可使按 Escape 键等同于单击相关按钮。button0Text button1Text button2Text defaultButtonNumber escapeButtonNumber
消息框是application modal 对话框。
警告: 请勿在执行对话框期间删除parent 。如果要删除,应使用QMessageBox 构造函数之一自行创建对话框。
另请参阅 information()、question() 和warning()。
[static, deprecated in 6.2]
int QMessageBox::information(QWidget *parent, const QString &title, const QString &text, int button0, int button1 = 0, int button2 = 0)
自 6.2 版起,该函数已被弃用。我们强烈建议不要在新代码中使用该函数。
请使用重载函数StandardButtons 。
使用给定的title 和text 打开一个信息消息框。对话框最多可以有三个按钮。每个按钮button0 、button1 和button2 都可以设置为以下值之一:
- QMessageBox::NoButton
- QMessageBox::Ok
- QMessageBox::Cancel
- QMessageBox::Yes
- QMessageBox::No
- QMessageBox::Abort
- QMessageBox::Retry
- QMessageBox::Ignore
- QMessageBox::YesAll
- QMessageBox::NoAll
如果不需要所有三个按钮,可将最后一个按钮或最后两个按钮设置为QMessageBox::NoButton 。
一个按钮可以与QMessageBox::Default OR 结 合,一个按钮可以与QMessageBox::Escape OR 结合。
返回被点击按钮的标识(QMessageBox::Ok 或QMessageBox::No 等)。
消息框是application modal 对话框。
警告: 请勿在执行对话框期间删除parent 。如果要删除,应使用QMessageBox 构造函数自行创建对话框。
另请参阅 question()、warning() 和critical()。
[static, deprecated in 6.2]
int QMessageBox::information(QWidget *parent, const QString &title, const QString &text, const QString &button0Text, const QString &button1Text = QString(), const QString &button2Text = QString(), int defaultButtonNumber = 0, int escapeButtonNumber = -1)
自 6.2 版起,该函数已被弃用。我们强烈建议不要在新代码中使用该函数。
请使用重载函数StandardButtons 。
这是一个重载函数。
使用给定的title 和text 以及一个、两个或三个按钮显示信息消息框。返回被点击按钮的索引(0、1 或 2)。
button0Text 是第一个按钮的文本,为可选项。 是第二个按钮的文本,为可选项。 是第三个按钮的文本,为可选项。 (0、1 或 2)是默认按钮的索引;按 Return 或 Enter 键与单击默认按钮相同。它的默认值为 0(第一个按钮)。 是转义按钮的索引;按 与单击该按钮相同。其默认值为-1;提供 0、1 或 2 可使按 与点击相关按钮相同。button0Text button1Text button2Text defaultButtonNumber escapeButtonNumber Esc Esc
消息框是application modal 对话框。
警告: 请勿在执行对话框期间删除parent 。如果要删除,应使用QMessageBox 构造函数之一自行创建对话框。
另请参阅 question()、warning() 和critical()。
[static, deprecated in 6.2]
int QMessageBox::question(QWidget *parent, const QString &title, const QString &text, int button0, int button1 = 0, int button2 = 0)
自 6.2 版起,该函数已被弃用。我们强烈建议不要在新代码中使用该函数。
请使用StandardButtons 的重载函数。
使用给定的title 和text 打开一个问题消息框。对话框最多可以有三个按钮。每个按钮button0 、button1 和button2 都可以设置为以下值之一:
- QMessageBox::NoButton
- QMessageBox::Ok
- QMessageBox::Cancel
- QMessageBox::Yes
- QMessageBox::No
- QMessageBox::Abort
- QMessageBox::Retry
- QMessageBox::Ignore
- QMessageBox::YesAll
- QMessageBox::NoAll
如果不需要所有三个按钮,可将最后一个按钮或最后两个按钮设置为QMessageBox::NoButton 。
一个按钮可以与QMessageBox::Default OR 结 合,一个按钮可以与QMessageBox::Escape OR 结合。
返回被点击按钮的标识(QMessageBox::Yes 或QMessageBox::No 等)。
消息框是application modal 对话框。
警告: 请勿在执行对话框期间删除parent 。如果要删除,应使用QMessageBox 构造函数自行创建对话框。
另请参阅 information()、warning() 和critical()。
[static, deprecated in 6.2]
int QMessageBox::question(QWidget *parent, const QString &title, const QString &text, const QString &button0Text, const QString &button1Text = QString(), const QString &button2Text = QString(), int defaultButtonNumber = 0, int escapeButtonNumber = -1)
自 6.2 版起,该函数已被弃用。我们强烈建议不要在新代码中使用该函数。
请使用重载函数StandardButtons 。
这是一个重载函数。
显示带有给定title 和text 以及一个、两个或三个按钮的问题消息框。返回被点击按钮的索引(0、1 或 2)。
button0Text 是第一个按钮的文本,为可选项。 是第二个按钮的文本,为可选项。 是第三个按钮的文本,为可选项。 (0、1 或 2)是默认按钮的索引;按 Return 或 Enter 键与单击默认按钮相同。它的默认值为 0(第一个按钮)。 是 Escape 按钮的索引;按下 Escape 与单击该按钮相同。默认值为-1;输入 0、1 或 2 可使按 Escape 键等同于单击相关按钮。button0Text button1Text button2Text defaultButtonNumber escapeButtonNumber
消息框是application modal 对话框。
警告: 请勿在执行对话框期间删除parent 。如果要删除,应使用QMessageBox 构造函数之一自行创建对话框。
另请参阅 information()、warning() 和critical()。
[deprecated in 6.2]
void QMessageBox::setButtonText(int button, const QString &text)
自 6.2 版起,该函数已被弃用。我们强烈建议不要在新代码中使用该函数。
将消息框按钮button 的文本设置为text 。设置消息框外按钮的文本将被静默忽略。
请使用addButton() 代替。
另请参阅 buttonText()。
[static, deprecated in 6.2]
QPixmap QMessageBox::standardIcon(QMessageBox::Icon icon)
自 6.2 版起,该函数已被弃用。我们强烈建议不要在新代码中使用该函数。
返回用于标准图标的像素图。icon 指定所需的图标,如QMessageBox::Question,QMessageBox::Information,QMessageBox::Warning 或QMessageBox::Critical 。
请使用QStyle::SP_MessageBoxInformation 等调用QStyle::standardIcon() 。
[static, deprecated in 6.2]
int QMessageBox::warning(QWidget *parent, const QString &title, const QString &text, int button0, int button1, int button2 = 0)
自 6.2 版起,该函数已被弃用。我们强烈建议不要在新代码中使用该函数。
请使用重载StandardButtons 。
使用给定的title 和text 打开一个警告消息框。对话框最多可以有三个按钮。每个按钮参数button0 、button1 和button2 都可以设置为以下值之一:
- QMessageBox::NoButton
- QMessageBox::Ok
- QMessageBox::Cancel
- QMessageBox::Yes
- QMessageBox::No
- QMessageBox::Abort
- QMessageBox::Retry
- QMessageBox::Ignore
- QMessageBox::YesAll
- QMessageBox::NoAll
如果不需要全部三个按钮,可将最后一个按钮或最后两个按钮设置为QMessageBox::NoButton 。
一个按钮可以与QMessageBox::Default OR 结 合,一个按钮可以与QMessageBox::Escape OR 结合。
返回被点击按钮的标识(QMessageBox::Ok 或QMessageBox::No 或...)。
消息框是application modal 对话框。
警告: 请勿在执行对话框期间删除parent 。如果要删除,应使用QMessageBox 构造函数自行创建对话框。
另请参阅 information()、question() 和critical()。
[static, deprecated in 6.2]
int QMessageBox::warning(QWidget *parent, const QString &title, const QString &text, const QString &button0Text, const QString &button1Text = QString(), const QString &button2Text = QString(), int defaultButtonNumber = 0, int escapeButtonNumber = -1)
自 6.2 版起,该函数已被弃用。我们强烈建议不要在新代码中使用该函数。
请使用重载函数StandardButtons 。
这是一个重载函数。
显示带有给定title 和text 以及一个、两个或三个按钮的警告消息框。返回被点击按钮的编号(0、1 或 2)。
button0Text 是第一个按钮的文本,为可选项。 是第二个按钮的文本,可选; 是第三个按钮的文本,可选。 (0、1 或 2)是默认按钮的索引;按 Return 或 Enter 与单击默认按钮相同。它的默认值为 0(第一个按钮)。 是 Escape 按钮的索引;按下 Escape 与单击该按钮相同。默认值为-1;输入 0、1 或 2 可使按 Escape 键等同于单击相关按钮。button0Text button1Text button2Text defaultButtonNumber escapeButtonNumber
消息框是application modal 对话框。
警告: 请勿在执行对话框期间删除parent 。如果要删除,应使用QMessageBox 构造函数之一自行创建对话框。
另请参阅 information()、question() 和critical()。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.