SettingsDialog: Fix default button

The default button would move to the first pushbutton that got focus.
E.g. tabbing through the android settings would move the default button
to the first button that got focus.

The cause of that is that for QPushButton::setDefault to work, the
button needs to be a child of the QDialog. So call it after adding
the buttongroup to the layout.

Change-Id: Ife35bf15aa8585f7931a87ee715f316bb02b36be
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
Daniel Teske
2014-11-21 17:49:05 +01:00
parent 0d9b254840
commit 5449e0a731

View File

@@ -412,7 +412,6 @@ void SettingsDialog::createGui()
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok |
QDialogButtonBox::Apply |
QDialogButtonBox::Cancel);
buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
connect(buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(apply()));
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
@@ -425,6 +424,9 @@ void SettingsDialog::createGui()
mainGridLayout->addWidget(buttonBox, 2, 0, 1, 2);
mainGridLayout->setColumnStretch(1, 4);
setLayout(mainGridLayout);
buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
setMinimumSize(1000, 550);
if (Utils::HostOsInfo::isMacHost())
setMinimumHeight(minimumHeight() * 1.1);