Press Escape key in QmessageBox Close Parent Window
-
Hi,
I'm using Qt5.1.0 in Ubuntu 13.04. The problem was I developed a Dialog based Application, in that app I had a warning message box with ok button and message box was modal. when message box appeared, I click Escape key without pressing of ok button to close message box, both message box and parent were closed. whats wrong in message box... any suggesstions please.. -
By default the Escape key closes the Dialog windows on Qt.
But did you get any error? Why is this a problem?If you want to eliminate this behaviour you should override the keyPressEvent function on your Dialog class the following:
@MyDialog::keyPressEvent(QKeyEvent *e) {
if(e->key() != Qt::Key_Escape)
QDialog::keyPressEvent(e);
}@ -
Thanks, Its works.. But I already use keypressevent in eventfilter, why that didn't work..