Running KMessageDialog *dialog = new KMessageDialog(KMessageDialog::WarningTwoActionsCancel, QStringLiteral("Hello")); QObject::connect(dialog, &QDialog::finished, [](int result){ qWarning() << "res" << result; }); dialog->show(); and then pressing Esc to close the dialog will print twice. One time with result QDialogButtonBox::Cancel, another time with 0. This does not happen when clicking the cancel button SOFTWARE/OS VERSIONS KDE Plasma Version: 6.0 KDE Frameworks Version: 6.0 Qt Version: 6.7 ADDITIONAL INFORMATION