From ee7b95f7d1f975c18603d98e877910d9d805ee8a Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Wed, 29 Apr 2009 14:34:23 +0200 Subject: Fix incorrect size hint for QGroupBox Cleanlooks/GTK These styles render using a bigger font than the one set on the groupbox. We basically have to recalculate the minimum size to ensure text is not clipped. Task-number: 16483 Reviewed-by: ogoffart --- src/gui/styles/qcleanlooksstyle.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/gui/styles/qcleanlooksstyle.cpp b/src/gui/styles/qcleanlooksstyle.cpp index 11f4d26..3fb63f2 100644 --- a/src/gui/styles/qcleanlooksstyle.cpp +++ b/src/gui/styles/qcleanlooksstyle.cpp @@ -3768,6 +3768,20 @@ QSize QCleanlooksStyle::sizeFromContents(ContentsType type, const QStyleOption * } break; case CT_GroupBox: + // Since we use a bold font we have to recalculate base width + if (const QGroupBox *gb = qobject_cast(widget)) { + QFont font = gb->font(); + font.setBold(true); + QFontMetrics metrics(font); + int baseWidth = metrics.width(gb->title()) + metrics.width(QLatin1Char(' ')); + if (gb->isCheckable()) { + baseWidth += pixelMetric(QStyle::PM_IndicatorWidth, option, widget); + baseWidth += pixelMetric(QStyle::PM_CheckBoxLabelSpacing, option, widget); + } + newSize.setWidth(qMax(baseWidth, newSize.width())); + } + newSize += QSize(0, 1); + break; case CT_RadioButton: case CT_CheckBox: newSize += QSize(0, 1); -- cgit v0.12