path: root/src
diff options
authorJan Arve Saether <>2014-04-29 14:15:42 +0200
committerThe Qt Project <>2014-04-30 12:38:42 +0200
commit92d289aba8207d2e95ff4117660f619e497f93e8 (patch)
treea65b91b09d17c872c10d6149e578068500c552ec /src
parentfd644f3bd0eee59a9cacfd0dd51a620c31c8e87d (diff)
Widgets going "undercover" should also undercover the QWindow
Sometimes Qt wants to hide a widget without calling setVisible(false). This is usually done by setting the widgets geometry outside the parents clip rect (and usually by setting its y coordinate to a sufficiently negative y coordinate). QSplitter uses this when it needs to collapse its children. Previously the QWindow was just moved straight above the QWidget it was hosted in. Task-number: QTBUG-38475 Change-Id: I154dd4d13f108c3d34c64eadb41dd6b477dc5c4e Reviewed-by: Friedemann Kleint <> Reviewed-by: Gunnar Sletta <>
Diffstat (limited to 'src')
1 files changed, 9 insertions, 2 deletions
diff --git a/src/widgets/kernel/qwindowcontainer.cpp b/src/widgets/kernel/qwindowcontainer.cpp
index 4618e1c91d..1770e60c2e 100644
--- a/src/widgets/kernel/qwindowcontainer.cpp
+++ b/src/widgets/kernel/qwindowcontainer.cpp
@@ -1,6 +1,6 @@
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact:
** This file is part of the QtWidgets module of the Qt Toolkit.
@@ -72,7 +72,14 @@ public:
void updateGeometry() {
- if (usesNativeWidgets)
+ if (q->geometry().bottom() <= 0 || q->geometry().right() <= 0)
+ /* Qt (e.g. QSplitter) sometimes prefer to hide a widget by *not* calling
+ setVisible(false). This is often done by setting its coordinates to a sufficiently
+ negative value so that its clipped outside the parent. Since a QWindow is not clipped
+ to widgets in general, it needs to be dealt with as a special case.
+ */
+ window->setGeometry(q->geometry());
+ else if (usesNativeWidgets)
window->setGeometry(QRect(q->mapTo(q->window(), QPoint()), q->size()));