How to return Qmessage box output to other function
Solved
General and Desktop
-
Hi and welcome
Not sure what is question is but let's say we have
QMessageBox msgBox;
msgBox.setText("The document has been modified.");
msgBox.setInformativeText("Do you want to save your changes?");
msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Save);
int ret = msgBox.exec();
Then ret has the result.so if you have it in a function
int AskTheUser() {
QMessageBox msgBox;
...
int ret = msgBox.exec();
return ret;
}then somewhere else
void someclass::somefunc() {
int result=AskUser();
if (result == QMessageBox::Save)
DOIT()
}