uic: Delay the setting of QPushButton::default.

For the property to take effect, the button must have its
parent set. This might not be the case when a container like
for example QTabWidget is involved. Move the setting of the
property to the bottom of setupUi.

Task-number: QTBUG-44406
Change-Id: Ic2013865a020986475fa28f2e3805c63d4de8ed0
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
This commit is contained in:
Friedemann Kleint 2015-04-21 08:25:28 +02:00
parent 6545404afa
commit c3737573ce
8 changed files with 28 additions and 9 deletions

View File

@ -1176,6 +1176,7 @@ void WriteInitialization::writeProperties(const QString &varName,
continue;
QString propertyName = p->attributeName();
QString propertyValue;
bool delayProperty = false;
// special case for the property `geometry': Do not use position
if (isTopLevel && propertyName == QLatin1String("geometry") && p->elementRect()) {
@ -1204,6 +1205,10 @@ void WriteInitialization::writeProperties(const QString &varName,
&& m_uic->customWidgetsInfo()->extends(className, QLatin1String("QAxWidget"))) {
// already done ;)
continue;
} else if (propertyName == QLatin1String("default")
&& m_uic->customWidgetsInfo()->extends(className, QLatin1String("QPushButton"))) {
// QTBUG-44406: Setting of QPushButton::default needs to be delayed until the parent is set
delayProperty = true;
} else if (propertyName == QLatin1String("database")
&& p->elementStringList()) {
// Sql support
@ -1479,7 +1484,7 @@ void WriteInitialization::writeProperties(const QString &varName,
else if (propertyName == QLatin1String("accessibleName") || propertyName == QLatin1String("accessibleDescription"))
defineC = accessibilityDefineC;
QTextStream &o = autoTrOutput(p);
QTextStream &o = delayProperty ? m_delayedOut : autoTrOutput(p);
if (defineC)
openIfndef(o, QLatin1String(defineC));

View File

@ -97,7 +97,6 @@ public:
browseTorrents = new QPushButton(groupBox);
browseTorrents->setObjectName(QStringLiteral("browseTorrents"));
browseTorrents->setDefault(true);
gridLayout->addWidget(browseTorrents, 0, 3, 1, 1);
@ -205,6 +204,9 @@ public:
QObject::connect(okButton, SIGNAL(clicked()), AddTorrentFile, SLOT(accept()));
QObject::connect(cancelButton, SIGNAL(clicked()), AddTorrentFile, SLOT(reject()));
browseTorrents->setDefault(true);
QMetaObject::connectSlotsByName(AddTorrentFile);
} // setupUi

View File

@ -688,7 +688,6 @@ public:
buttonOk = new QPushButton(Config);
buttonOk->setObjectName(QStringLiteral("buttonOk"));
buttonOk->setAutoDefault(true);
buttonOk->setDefault(true);
hboxLayout3->addWidget(buttonOk);
@ -706,6 +705,9 @@ public:
QObject::connect(size_width, SIGNAL(valueChanged(int)), size_custom, SLOT(click()));
QObject::connect(size_height, SIGNAL(valueChanged(int)), size_custom, SLOT(click()));
buttonOk->setDefault(true);
QMetaObject::connectSlotsByName(Config);
} // setupUi

View File

@ -164,7 +164,6 @@ public:
vboxLayout1->setObjectName(QStringLiteral("vboxLayout1"));
findNxt = new QPushButton(FindDialog);
findNxt->setObjectName(QStringLiteral("findNxt"));
findNxt->setDefault(true);
findNxt->setFlat(false);
vboxLayout1->addWidget(findNxt);
@ -194,6 +193,9 @@ public:
retranslateUi(FindDialog);
QObject::connect(cancel, SIGNAL(clicked()), FindDialog, SLOT(reject()));
findNxt->setDefault(true);
QMetaObject::connectSlotsByName(FindDialog);
} // setupUi

View File

@ -171,7 +171,6 @@ public:
okButton = new QPushButton(QSqlConnectionDialogUi);
okButton->setObjectName(QStringLiteral("okButton"));
okButton->setDefault(true);
hboxLayout1->addWidget(okButton);
@ -202,6 +201,9 @@ public:
retranslateUi(QSqlConnectionDialogUi);
okButton->setDefault(true);
QMetaObject::connectSlotsByName(QSqlConnectionDialogUi);
} // setupUi

View File

@ -86,7 +86,6 @@ public:
connectButton = new QPushButton(Form);
connectButton->setObjectName(QStringLiteral("connectButton"));
connectButton->setEnabled(true);
connectButton->setDefault(true);
vboxLayout->addWidget(connectButton);
@ -136,7 +135,6 @@ public:
sendButton->setObjectName(QStringLiteral("sendButton"));
sendButton->setEnabled(false);
sendButton->setFocusPolicy(Qt::TabFocus);
sendButton->setDefault(true);
hboxLayout1->addWidget(sendButton);
@ -151,6 +149,10 @@ public:
QObject::connect(hostNameEdit, SIGNAL(returnPressed()), connectButton, SLOT(animateClick()));
QObject::connect(sessionInput, SIGNAL(returnPressed()), sendButton, SLOT(animateClick()));
connectButton->setDefault(true);
sendButton->setDefault(true);
QMetaObject::connectSlotsByName(Form);
} // setupUi

View File

@ -77,7 +77,6 @@ public:
buttonDisplay = new QPushButton(Layout16);
buttonDisplay->setObjectName(QStringLiteral("buttonDisplay"));
buttonDisplay->setAutoDefault(true);
buttonDisplay->setDefault(true);
hboxLayout->addWidget(buttonDisplay);
@ -96,6 +95,9 @@ public:
retranslateUi(TopicChooser);
buttonDisplay->setDefault(true);
QMetaObject::connectSlotsByName(TopicChooser);
} // setupUi

View File

@ -164,7 +164,6 @@ public:
vboxLayout2->setContentsMargins(0, 0, 0, 0);
findNxt = new QPushButton(TranslateDialog);
findNxt->setObjectName(QStringLiteral("findNxt"));
findNxt->setDefault(true);
findNxt->setFlat(false);
vboxLayout2->addWidget(findNxt);
@ -206,6 +205,9 @@ public:
retranslateUi(TranslateDialog);
QObject::connect(cancel, SIGNAL(clicked()), TranslateDialog, SLOT(reject()));
findNxt->setDefault(true);
QMetaObject::connectSlotsByName(TranslateDialog);
} // setupUi