Details
-
Bug
-
Resolution: Unresolved
-
P4: Low
-
None
-
5.10.0
-
None
-
* Archlinux
* {{QT 5.10}}
Description
QDialogButtonBox says in it's documentation:
If you want a specific button to be default you need to call QPushButton::setDefault() on it yourself. However, if there is no default button set and to preserve which button is the default button across platforms when using the QPushButton::autoDefault property, the first push button with the accept role is made the default button when the QDialogButtonBox is shown,
But that's not the case. If you add only a cancel button (which has the reject role), it will be the default button.
I created an example, by using the ConfigDialog example. Therefore I added two lines in line 90 of configdialog.cpp:
QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Cancel, Qt::Horizontal, this);
connect(buttons, &QDialogButtonBox::rejected, this, &QWidget::close);
If you start the example and press enter, the dialog closes because of the cancel button.