PDA

View Full Version : How to close the dialog using close(X) button or cancel push button?



Gokulnathvc
6th May 2011, 07:21
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?

FelixB
6th May 2011, 07:52
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.

ChrisW67
6th May 2011, 08:02
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.