summaryrefslogtreecommitdiffstats
path: root/src/gui/styles
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-03-27 14:20:14 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-03-27 14:35:27 (GMT)
commit062c476d378022a49307aca136cb9aab381e0814 (patch)
tree03647c2feb10eb4096842e8a389e7902331392a7 /src/gui/styles
parente48709416ad314f30d8ea35fc386cb177bb4b32d (diff)
downloadQt-062c476d378022a49307aca136cb9aab381e0814.zip
Qt-062c476d378022a49307aca136cb9aab381e0814.tar.gz
Qt-062c476d378022a49307aca136cb9aab381e0814.tar.bz2
Fix background of QAbstractScrollArea when styled only with pseudo-class
This may happen if you only have something like QAbstractScrollArea:focus { background: foo; } and you do not have a background set for the general case and the viewport has a different background role (such as QTextEdit, QAbstractItemView, ....) This is a regression from 4.4 since in 4.4 the :focus has no effect if you didn't have a background for the general case. Reviewed-by: bnilsen Task-number: 188195
Diffstat (limited to 'src/gui/styles')
-rw-r--r--src/gui/styles/qstylesheetstyle.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp
index f22cd56..a39eeb7 100644
--- a/src/gui/styles/qstylesheetstyle.cpp
+++ b/src/gui/styles/qstylesheetstyle.cpp
@@ -2916,6 +2916,10 @@ void QStyleSheetStyle::polish(QWidget *w)
if (ew->autoFillBackground()) {
ew->setAutoFillBackground(false);
autoFillDisabledWidgets->insert(w);
+ if (ew != w) { //eg. viewport of a scrollarea
+ //(in order to draw the background anyway in case we don't.)
+ ew->setAttribute(Qt::WA_StyledBackground, true);
+ }
}
if (!rule.hasBackground() || rule.background()->isTransparent() || rule.hasBox()
|| (!rule.hasNativeBorder() && !rule.border()->isOpaque()))
@@ -4345,8 +4349,16 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op
return;
case PE_Widget:
- if (!rule.hasBackground())
+ if (!rule.hasBackground()) {
+ QWidget *container = containerWidget(w);
+ if (autoFillDisabledWidgets->contains(container)
+ && (container == w || !renderRule(container, opt).hasBackground())) {
+ //we do not have a background, but we disabled the autofillbackground anyway. so fill the background now.
+ // (this may happen if we have rules like :focus)
+ p->fillRect(opt->rect, opt->palette.brush(w->backgroundRole()));
+ }
break;
+ }
#ifndef QT_NO_SCROLLAREA
if (const QAbstractScrollArea *sa = qobject_cast<const QAbstractScrollArea *>(w)) {