if ((frameStyle != QFrame::NoFrame) &&
q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, &opt, q)) {
controlsRect = widgetRect;
- const int extra = scrollOverlap;
+ const int extra = scrollOverlap + 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());
#include <qradiobutton.h>
#include <qlineedit.h>
#include <qmdiarea.h>
+#include <qscrollarea.h>
#include <QCleanlooksStyle>
#endif
void defaultFont();
void testDrawingShortcuts();
+ void testFrameOnlyAroundContents();
private:
void lineUpLayoutTest(QStyle *);
QWidget *testWidget;
int alignment;
};
+
void tst_QStyle::testDrawingShortcuts()
{
{
}
}
+#define SCROLLBAR_SPACING 33
+
+class FrameTestStyle : public QWindowsStyle {
+ int styleHint(StyleHint hint, const QStyleOption *opt, const QWidget *widget, QStyleHintReturn *returnData) const {
+ if (hint == QStyle::SH_ScrollView_FrameOnlyAroundContents)
+ return 1;
+ return QWindowsStyle ::styleHint(hint, opt, widget, returnData);
+ }
+
+ int pixelMetric(PixelMetric pm, const QStyleOption *option, const QWidget *widget) const {
+ if (pm == QStyle::PM_ScrollView_ScrollBarSpacing)
+ return SCROLLBAR_SPACING;
+ return QWindowsStyle ::pixelMetric(pm, option ,widget);
+ }
+};
+
+void tst_QStyle::testFrameOnlyAroundContents()
+{
+ QScrollArea area;
+ area.setGeometry(0, 0, 200, 200);
+ QWindowsStyle winStyle;
+ FrameTestStyle frameStyle;
+ QWidget *widget = new QWidget(&area);
+ widget->setGeometry(0, 0, 400, 400);
+ area.setStyle(&winStyle);
+ area.verticalScrollBar()->setStyle(&winStyle);
+ area.setWidget(widget);
+ area.setVisible(true);
+ int viewPortWidth = area.viewport()->width();
+ area.verticalScrollBar()->setStyle(&frameStyle);
+ area.setStyle(&frameStyle);
+ // Test that we reserve space for scrollbar spacing
+ QVERIFY(viewPortWidth == area.viewport()->width() + SCROLLBAR_SPACING);
+}
+
+
QTEST_MAIN(tst_QStyle)
#include "tst_qstyle.moc"