PDA

View Full Version : QDialog - how to stop hide on "ESC"?



will49
27th May 2008, 15:10
I have a modal dialog box that I need to be displayed until I'm finished some processing. However the user can close/hide the dialog by pressing the "ESC" key. How can I override this default behavior in QDialog so I can stop it from doing this?

jpn
27th May 2008, 16:10
If the user presses the Esc key in a dialog, QDialog::reject() will be called. You can reimplement that function to do nothing under certain circumstances:


void MyDialog::reject()
{
if (itsOkToClose)
{
QDialog::reject();
}
}

will49
27th May 2008, 16:40
Great. That worked.