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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With