How to close the current dialog using X close button or the cancel push button in the dialog? When pressing either of the buttons, the current dialog should close and the rest of the codes should be ignored?
How to close the current dialog using X close button or the cancel push button in the dialog? When pressing either of the buttons, the current dialog should close and the rest of the codes should be ignored?
the "x-Button" behaviour is automatically implemented (assuming you mean the button top right which is generated automatically).
to close via "cancel", you have to connect the clicked()-signal of this button with the "close()"-slot of your dialog.
Groan. Please read at least a few pages of the documentation and try something for yourself before asking how you can implement default behaviour (the close [X] widget) or behaviour that is adequately covered in the QDialog manual page and any number of the bundled examples.
You want QDialog::reject() to "cancel" the dialog, or QDialog::accept() to "OK" the dialog.
Bookmarks