QDialog close action on pressing Window 'X'
-
Hi,
Trying to implement a QDialog where on click of 'X' on the window toolbar should show up a QMessageBox with the QDialog in backgroud.
I initially tried listening to signal QDialog::finish, and on this signal; dynamically created a QMessageBox and also added the attribute WA_DeleteOnClose = false on my QDialog.
But, when I click on 'X'; the window closes, shows the message box (on accepting the message box; the entire dialog closes and reject; the dialog should stay) --> the QDialog box is not seen in the background.
I'd like the Qdialog to stay in the background when the QMessageBox opens up.
Any help?
-
Hi,
Trying to implement a QDialog where on click of 'X' on the window toolbar should show up a QMessageBox with the QDialog in backgroud.
I initially tried listening to signal QDialog::finish, and on this signal; dynamically created a QMessageBox and also added the attribute WA_DeleteOnClose = false on my QDialog.
But, when I click on 'X'; the window closes, shows the message box (on accepting the message box; the entire dialog closes and reject; the dialog should stay) --> the QDialog box is not seen in the background.
I'd like the Qdialog to stay in the background when the QMessageBox opens up.
Any help?
@DeeDee14
I have not followed the detail but do you want to show the message box by subclassingQDialogand overriding QDialog::closeEvent(QCloseEvent *e)? See also the example at QWidget::closeEvent(QCloseEvent *event), is that what you are wanting to do? -
@DeeDee14
I have not followed the detail but do you want to show the message box by subclassingQDialogand overriding QDialog::closeEvent(QCloseEvent *e)? See also the example at QWidget::closeEvent(QCloseEvent *event), is that what you are wanting to do?@JonB Trying to implement something like this:

Where on click of 'X'; the message box shows up and on click of cancel on messageBox, I remain on QDialog.
Currently, on click of 'X' - the Dialog closes; shows the message box. And on clicking cancel on the messageBox; the dialogs shows again.
This is how I tried implementing it:
dialog->setAttribute(Qt::WA_DeleteOnClose, false); QObject::connect(dialog, SIGNAL(finished), this, [this](){ // create a message box }); -
@JonB Trying to implement something like this:

Where on click of 'X'; the message box shows up and on click of cancel on messageBox, I remain on QDialog.
Currently, on click of 'X' - the Dialog closes; shows the message box. And on clicking cancel on the messageBox; the dialogs shows again.
This is how I tried implementing it:
dialog->setAttribute(Qt::WA_DeleteOnClose, false); QObject::connect(dialog, SIGNAL(finished), this, [this](){ // create a message box });