Reset geometry constraints when removing stylesheet

CSS geometry constraints such as "min-height" or "min-width"
will set size constraints on the widget.

Removing the stylesheet should remove these constraints.

Task-Id: QTBUG-69418
Change-Id: I1008e4390281c90112303d72dd7d59a8acddfcd9
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
bb10
Sergio Martins 2018-07-11 14:01:10 +01:00 committed by Sérgio Martins
parent 37bd2400fa
commit 856284d525
2 changed files with 13 additions and 4 deletions

View File

@ -2905,10 +2905,7 @@ void QStyleSheetStyle::unpolish(QWidget *w)
styleSheetCaches->renderRulesCache.remove(w);
styleSheetCaches->styleSheetCache.remove(w);
unsetPalette(w);
w->setProperty("_q_stylesheet_minw", QVariant());
w->setProperty("_q_stylesheet_minh", QVariant());
w->setProperty("_q_stylesheet_maxw", QVariant());
w->setProperty("_q_stylesheet_maxh", QVariant());
setGeometry(w);
w->setAttribute(Qt::WA_StyleSheet, false);
QObject::disconnect(w, 0, this, 0);
#if QT_CONFIG(scrollarea)

View File

@ -98,6 +98,7 @@ private slots:
void widgetStyle();
void appStyle();
void QTBUG11658_cachecrash();
void unpolish();
private:
QColor COLOR(const QWidget& w) {
w.ensurePolished();
@ -1999,6 +2000,17 @@ void tst_QStyleSheetStyle::widgetStylePropagation()
QCOMPARE(COLOR(childLabel), childExpectedColor);
}
void tst_QStyleSheetStyle::unpolish()
{
QWidget w;
QCOMPARE(w.minimumWidth(), 0);
w.setStyleSheet("QWidget { min-width: 100; }");
w.ensurePolished();
QCOMPARE(w.minimumWidth(), 100);
w.setStyleSheet("");
QCOMPARE(w.minimumWidth(), 0);
}
QTEST_MAIN(tst_QStyleSheetStyle)
#include "tst_qstylesheetstyle.moc"