Please tell me where I made a mistake? My code:
void deletetable::on_pb_dell_clicked()
{
QMessageBox messageBox(QMessageBox::Question,
tr("Sure want to quit?"), tr("Sure to quit?"), QMessageBox::Yes | QMessageBox::No, this);
messageBox.setButtonText(QMessageBox::Yes, tr("Yes"));
messageBox.setButtonText(QMessageBox::No, tr("No"));
messageBox.exec();
if (messageBox.QMessageBox::Yes) {
emit deleteYear(year);
close();
} else {
}
}
my function deleteYear(year)
works in any condition, i.e. if I click "No", the function will still work.
I took an example from here https://stackoverflow.com/a/31533126/13023647