From 620e7d82b34624f6765daf32917b12ab0e2249b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Thu, 6 Aug 2009 13:18:24 +0200 Subject: Make sure QWidget::setStyle() relayouts its children. Changing a style on a widget should invalidate the widget's layout, since the layouts spacings and margins may depend on the style. One optimization could be to check to see if the spacing and margins have changed due to the style change, but the old style is not available in changeEvent, so we'll keep it simple for now. RevBy: paul Task: 256986 --- src/gui/kernel/qwidget.cpp | 4 +++- tests/auto/qboxlayout/tst_qboxlayout.cpp | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 60a6b7a..f705761 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -7990,10 +7990,12 @@ void QWidget::changeEvent(QEvent * event) case QEvent::FontChange: case QEvent::StyleChange: { + Q_D(QWidget); update(); updateGeometry(); + if (d->layout) + d->layout->invalidate(); #ifdef Q_WS_QWS - Q_D(QWidget); if (isWindow()) d->data.fstrut_dirty = true; #endif diff --git a/tests/auto/qboxlayout/tst_qboxlayout.cpp b/tests/auto/qboxlayout/tst_qboxlayout.cpp index 642bc77..5803985 100644 --- a/tests/auto/qboxlayout/tst_qboxlayout.cpp +++ b/tests/auto/qboxlayout/tst_qboxlayout.cpp @@ -240,7 +240,6 @@ void tst_QBoxLayout::setStyleShouldChangeSpacing() window->setStyle(style2); QTest::qWait(100); spacing = pb2->geometry().left() - pb1->geometry().right() - 1; - QEXPECT_FAIL("", "Fix for next minor release", Continue); QCOMPARE(spacing, 10); delete window; -- cgit v0.12