diff --git a/src/kmessagebox.cpp b/src/kmessagebox.cpp --- a/src/kmessagebox.cpp +++ b/src/kmessagebox.cpp @@ -347,6 +347,16 @@ } buttons->setParent(dialog); + + // try to set the focus to a default button. + Q_FOREACH(QAbstractButton* button, buttons->buttons()) { + QPushButton* btn = dynamic_cast(button); + + if (btn != nullptr && btn->isDefault()) { + btn->setFocus(); + } + } + topLayout->addWidget(buttons); if (!usingListWidget && !usingScrollArea && !usingSqueezedTextLabel && details.isEmpty()) {