From 31c6bee4d5f314e184fc64a6a655fcfa1ea3fb60 Mon Sep 17 00:00:00 2001 From: Karim Pinter Date: Tue, 5 Apr 2016 11:45:43 +0300 Subject: Removes spacing when widget is hidden in QGridLayout Removes spacing in QGridLayout when the QWidgets inside of the QGridLayout are hidden, by checking if the sibling is empty, thus duplicate spacing can be avoided. Task-number: QTBUG-52357 Change-Id: I45475e7b264f94ef3bec5f9a4b8cbaa1d53ec6dd Reviewed-by: Karim Pinter Reviewed-by: Andy Shaw --- src/widgets/kernel/qgridlayout.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/widgets/kernel') diff --git a/src/widgets/kernel/qgridlayout.cpp b/src/widgets/kernel/qgridlayout.cpp index b58e7fdc9e..29df38f19c 100644 --- a/src/widgets/kernel/qgridlayout.cpp +++ b/src/widgets/kernel/qgridlayout.cpp @@ -746,9 +746,13 @@ void QGridLayoutPrivate::setupSpacings(QVector &chain, if (orientation == Qt::Vertical) { QGridBox *sibling = vReversed ? previousBox : box; if (sibling) { - QWidget *wid = sibling->item()->widget(); - if (wid) - spacing = qMax(spacing, sibling->item()->geometry().top() - wid->geometry().top() ); + if (sibling->item()->isEmpty()) { + spacing = 0; + } else { + QWidget *wid = sibling->item()->widget(); + if (wid) + spacing = qMax(spacing, sibling->item()->geometry().top() - wid->geometry().top()); + } } } } -- cgit v1.2.3