【问题标题】:QMessageBox without Icon没有图标的 QMessageBox
【发布时间】:2017-12-01 05:47:41
【问题描述】:

通常,创建QMessageBox 时,窗口图标将如下所示:

但我想要一个没有窗口/标题栏图标的QMessageBox,像这样:

我做了一些研究,发现我必须使用QMessageBox::NoIcon。我试过了,但它并没有真正奏效。

那么我该怎么做才能删除QMessageBox 图标?

【问题讨论】:

    标签: windows qt qmessagebox


    【解决方案1】:

    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();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-12-10
      • 1970-01-01
      • 2011-04-02
      • 2012-06-27
      • 1970-01-01
      • 2021-11-07
      • 1970-01-01
      相关资源
      最近更新 更多