Solved How to customise a message box with no "close" button?
-
Here is what I have currently:
QMessageBox::StandardButton reply; if (!saved) { reply = QMessageBox::question(this, tr("Question"), tr("Do you want to save changes?"), QMessageBox::Yes|QMessageBox::No|QMessageBox::Close); if (reply == QMessageBox::Yes) { if (model.name == "Untitled.emx") saveAs(); else save(); } else if (reply == QMessageBox::Close) return false; } return true;
How can I have the close option (via the "x"), but not have the "close" titled button?
-
Hi
Do you mean to have it return QMessageBox::Close for 'X'
when that button is not added?
I don't think that is possible.However, remove QMessageBox::Close and put MessageBox::question in a function.
Then look what it returns when using 'X' and simply return QMessageBox::Close to caller instead. -
@mrjj Yes, it returns 65536 when I click "x" and there's no "close" button.
-
@mrjj ...which is "no" (QMessageBox::No), so I guess it can't be done.
-
Hi,
What is your goal ? Something like Yes/No/Cancel ? In that case, QMessageBox::Cancel would make more sense.
-
@SGaist said in How to customise a message box with no "close" button?:
QMessageBox::Cancel
Yeah that makes more sense.