tags:

views:

40

answers:

1

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?

+3  A: 

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

Lars
Excellent, just what I needed - thank you!
Jake Petroules