summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/styles/qstylesheetstyle.cpp16
-rw-r--r--src/gui/widgets/qabstractscrollarea.cpp2
-rw-r--r--tests/auto/uiloader/baseline/css_scroll.ui14
3 files changed, 23 insertions, 9 deletions
diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp
index c550938..285a789 100644
--- a/src/gui/styles/qstylesheetstyle.cpp
+++ b/src/gui/styles/qstylesheetstyle.cpp
@@ -4242,8 +4242,15 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op
if (const QAbstractScrollArea *sa = qobject_cast<const QAbstractScrollArea *>(w)) {
const QAbstractScrollAreaPrivate *sap = sa->d_func();
rule.drawBackground(p, opt->rect, sap->contentsOffset());
- if (rule.hasBorder())
- rule.drawBorder(p, rule.borderRect(opt->rect));
+ if (rule.hasBorder()) {
+ QRect brect = rule.borderRect(opt->rect);
+ if (styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, opt, w)) {
+ QRect r = brect.adjusted(0, 0, sa->verticalScrollBar()->isVisible() ? -sa->verticalScrollBar()->width() : 0,
+ sa->horizontalScrollBar()->isVisible() ? -sa->horizontalScrollBar()->height() : 0);
+ brect = QStyle::visualRect(opt->direction, brect, r);
+ }
+ rule.drawBorder(p, brect);
+ }
break;
}
#endif
@@ -4628,6 +4635,11 @@ int QStyleSheetStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const
return msz.width() == -1 ? msz.height() : msz.width();
}
break;
+
+ case PM_ScrollView_ScrollBarSpacing:
+ if(!rule.hasNativeBorder() || rule.hasBox())
+ return 0;
+ break;
#endif // QT_NO_SCROLLBAR
case PM_ProgressBarChunkWidth:
diff --git a/src/gui/widgets/qabstractscrollarea.cpp b/src/gui/widgets/qabstractscrollarea.cpp
index 1d496d5..73ec53e 100644
--- a/src/gui/widgets/qabstractscrollarea.cpp
+++ b/src/gui/widgets/qabstractscrollarea.cpp
@@ -394,7 +394,7 @@ void QAbstractScrollAreaPrivate::layoutChildren()
if ((frameStyle != QFrame::NoFrame) &&
q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, &opt, q)) {
controlsRect = widgetRect;
- const int extra = q->style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarSpacing);
+ const int extra = q->style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarSpacing, &opt, q);
const QPoint cornerExtra(needv ? extra : 0, needh ? extra : 0);
QRect frameRect = widgetRect;
frameRect.adjust(0, 0, -cornerOffset.x() - cornerExtra.x(), -cornerOffset.y() - cornerExtra.y());
diff --git a/tests/auto/uiloader/baseline/css_scroll.ui b/tests/auto/uiloader/baseline/css_scroll.ui
index 0537ab0..6ac6886 100644
--- a/tests/auto/uiloader/baseline/css_scroll.ui
+++ b/tests/auto/uiloader/baseline/css_scroll.ui
@@ -14,8 +14,10 @@
<string>Form</string>
</property>
<property name="styleSheet">
- <string notr="true">QScrollArea { background:red; }
-QScrollArea .QWidget { background:transparent; }
+ <string notr="true">QScrollArea { background:red;
+ border: 5px dashed blue; }
+QScrollArea .QWidget { background:transparent;
+ border: 5px dotted green;}
QScrollArea::corner { background:yellow; }
@@ -111,10 +113,10 @@ QScrollArea::corner { background:yellow; }
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
- <x>-60</x>
- <y>-145</y>
- <width>554</width>
- <height>575</height>
+ <x>0</x>
+ <y>0</y>
+ <width>520</width>
+ <height>532</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_3">