summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/kernel/qwidget.cpp16
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp18
2 files changed, 4 insertions, 30 deletions
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index d436ffb..6026821 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -5674,15 +5674,10 @@ void QWidget::setFocus(Qt::FocusReason reason)
w = w->isWindow() ? 0 : w->parentWidget();
}
} else {
- while (w && w->isVisible()) {
+ while (w) {
w->d_func()->focus_child = f;
w = w->isWindow() ? 0 : w->parentWidget();
}
- // a special case, if there is an invisible parent, notify him
- // about the focus_child widget, so that if it becomes
- // visible, the focus widget will be respected.
- if (w)
- w->d_func()->focus_child = f;
}
#ifndef QT_NO_GRAPHICSVIEW
@@ -5757,8 +5752,9 @@ void QWidget::setFocus(Qt::FocusReason reason)
void QWidget::clearFocus()
{
QWidget *w = this;
- while (w && w->d_func()->focus_child == this) {
- w->d_func()->focus_child = 0;
+ while (w) {
+ if (w->d_func()->focus_child == this)
+ w->d_func()->focus_child = 0;
w = w->parentWidget();
}
#ifndef QT_NO_GRAPHICSVIEW
@@ -6734,10 +6730,6 @@ void QWidgetPrivate::show_helper()
if (QApplicationPrivate::hidden_focus_widget == q) {
QApplicationPrivate::hidden_focus_widget = 0;
q->setFocus(Qt::OtherFocusReason);
- } else if (focus_child) {
- // if we are shown and there is an explicit focus child widget
- // set, respect it by giving him focus.
- focus_child->setFocus(Qt::OtherFocusReason);
}
// Process events when showing a Qt::SplashScreen widget before the event loop
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
index 3fad366..041aa7a 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -351,7 +351,6 @@ private slots:
void toplevelLineEditFocus();
void focusWidget_task254563();
- void focusWidget_mixed_widget_hierarchy();
private:
bool ensureScreenSize(int width, int height);
@@ -8995,22 +8994,5 @@ void tst_QWidget::focusWidget_task254563()
QVERIFY(top.focusWidget() != widget); //dangling pointer
}
-void tst_QWidget::focusWidget_mixed_widget_hierarchy()
-{
- QWidget top;
- top.show();
- QWidget notvisible(&top);
- QWidget *visible = new QWidget(&notvisible);
- visible->show();
-
- visible->setFocus();
- notvisible.setFocus();
- notvisible.show();
- QCOMPARE(top.focusWidget(), visible);
- QCOMPARE(notvisible.focusWidget(), visible);
- QCOMPARE(visible->focusWidget(), visible);
-}
-
-
QTEST_MAIN(tst_QWidget)
#include "tst_qwidget.moc"