[英]How to make QDialogButtonBox NOT close its parent QDialog?
I have a QDialog with a QDialogButtonBox widget, and I've connected the button box's accepted signal to a slot in my QDialog subclass, like so: 我有一个QDialog和一个QDialogButtonBox小部件,我已经将按钮框的接受信号连接到我的QDialog子类中的一个插槽,如下所示:
void MyDialog::on_buttonBox_accepted()
{
QString errorString = this->inputErrorString();
if (errorString.isEmpty())
{
// Do work here
// code code code...
this->accept();
}
else
{
QMessageBox::critical(this, tr("Error"), tr("The following input errors have occurred:") + errorString);
}
}
However, the dialog is closes after the message box is displayed; 但是,在显示消息框后,对话框将关闭; apparently the button box automatically connects its accepted signal to QDialog's accept slot (I want to call that slot manually).
显然按钮框自动将其接受的信号连接到QDialog的接受槽(我想手动调用该槽)。 How can I prevent this so I can take the manual approach outlined above?
我如何防止这种情况,以便采取上述手动方法?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.