【发布时间】:2017-12-01 05:47:41
【问题描述】:
通常,创建QMessageBox 时,窗口图标将如下所示:
但我想要一个没有窗口/标题栏图标的QMessageBox,像这样:
我做了一些研究,发现我必须使用QMessageBox::NoIcon。我试过了,但它并没有真正奏效。
那么我该怎么做才能删除QMessageBox 图标?
【问题讨论】:
标签: windows qt qmessagebox
通常,创建QMessageBox 时,窗口图标将如下所示:
但我想要一个没有窗口/标题栏图标的QMessageBox,像这样:
我做了一些研究,发现我必须使用QMessageBox::NoIcon。我试过了,但它并没有真正奏效。
那么我该怎么做才能删除QMessageBox 图标?
【问题讨论】:
标签: windows qt qmessagebox
QMessageBox::NoIcon 不用于标题栏图标:它用于消息框中的大图标。
为了移除标题栏图标,你必须设置特定的标志:
QMessageBox msgBox(QMessageBox::Question,
"This is the title",
"This is the text",
QMessageBox::Yes | QMessageBox::No, this);
// set the flags you want: here is the case when you want to keep the close button
msgBox.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
msgBox.exec();
【讨论】: