Qt 6.11 is out! See what's new in the release
blog
Press Escape key in QmessageBox Close Parent Window
General and Desktop
3
Posts
2
Posters
2.6k
Views
1
Watching
-
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);
}@