QMessageBox标题栏关闭不可用问题

继承QMessageBox的类的提示框,怎么控制标题栏关闭按钮是否可用????
现在是不可用,我想设置成可用

1个回答

默认的应该是可用的才对,不可用试试这个:

 Qt::WindowFlags wFlags = mBox.windowFlags();
if(Qt::WindowCloseButtonHint == (wFlags & Qt::WindowCloseButtonHint))
{
    wFlags = wFlags ^ Qt::WindowCloseButtonHint;
    mBox.setWindowFlags(wFlags);
}
yhq412
to be continue int CustomMsg::MyWarning (QWidget* parent, QString title, QString &text, QString &btnText1, QString &btnText2){QMessageBox customsg;custommsg.setWindowTitle(title);customsg.setText(text);QPushButton btn1, btn2;btn1 = customsg.addButton(btnText1, QMessageBox::ActionRole);btn1=customsg.addButton(btnText1, QMessageBox::ActionRole);btn1 =customsg.addButton(btnText1, QMessageBox::ActionRole);btn2 = customsg.addButton(btnText2, QMessageBox::ActionRole); customsg.exec();}//关闭按钮是灰色的不可点击
2 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问