From ae0fd6884d30ae2ce084e239468696aaec7f5795 Mon Sep 17 00:00:00 2001 From: Christoph Schleifenbaum Date: Thu, 22 Dec 2011 19:33:28 +0100 Subject: QAbstractScrollArea - add SizeAdjustPolicy and viewportSizeHint This patch adds SizeAdjustPolicy to QAbstractScrollArea. If it is set to AdjustToContents it will make use of the new protected viewportSizeHint() (BC since it was reserved in Qt5). This function returns a suggested size based on contents. Change-Id: I5d8aa517e88b8b21c5712e62b4d574c3aad99d3b Reviewed-by: Stephen Kelly --- src/widgets/widgets/qscrollarea.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/widgets/widgets/qscrollarea.cpp') diff --git a/src/widgets/widgets/qscrollarea.cpp b/src/widgets/widgets/qscrollarea.cpp index 93c335c56b..2a6d4620d7 100644 --- a/src/widgets/widgets/qscrollarea.cpp +++ b/src/widgets/widgets/qscrollarea.cpp @@ -407,6 +407,18 @@ QSize QScrollArea::sizeHint() const return sz.boundedTo(QSize(36 * h, 24 * h)); } +/*! + \reimp + */ +QSize QScrollArea::viewportSizeHint() const +{ + Q_D(const QScrollArea); + if (d->widget) { + return d->resizable ? d->widget->sizeHint() : d->widget->size(); + } + const int h = fontMetrics().height(); + return QSize(6 * h, 4 * h); +} /*! -- cgit v1.2.3