Narek Narek - 1 month ago 13
C++ Question

Qt - Esc should not close the dialog

How to make Esc key to minimize a dialog? By default it closes. Should I process

KeyEvent
or there is a better way?

Answer

I think you may use this:

MyDialog::keyPressEvent(QKeyEvent *e) {
    if(e->key() != Qt::Key_Escape)
        QDialog::keyPressEvent(e);
    else {/* minimize */}
}

Also have a look at Events and Event Filters docs.