开发者

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:

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). How can I prevent this so I can take the manual approach outlined above?


You can implement MyDialog::accept(). The function is virtual in QDialog.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜