From 6affa9890d0acd51b0b4d63e4ac33323e392ee48 Mon Sep 17 00:00:00 2001 From: Ghenady Kuznetsov Date: Mon, 1 Jan 2024 19:25:20 +0200 Subject: [PATCH] Fusion style: add clip region for groupbox title Fusion style is missing clip region for the title in QFusionStyle::drawComplexControl(). Without that region, the top line of the frame will be visible behind the vertically centered title. Fixes: QTBUG-121041 Pick-to: 6.6 Change-Id: I3daf5854195e28a5ee3cb50343e2dd56e66ed940 Reviewed-by: Timur Pocheptsov Reviewed-by: Christian Ehrlicher (cherry picked from commit 9b4c35abff94a708139923a32c38a749cbdfd130) Reviewed-by: Qt Cherry-pick Bot --- src/widgets/styles/qfusionstyle.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 9a42ac579e2..3535685a2dd 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -1837,7 +1837,23 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption frame.lineWidth = groupBox->lineWidth; frame.midLineWidth = groupBox->midLineWidth; frame.rect = proxy()->subControlRect(CC_GroupBox, option, SC_GroupBoxFrame, widget); + painter->save(); + QRegion region(groupBox->rect); + if (!groupBox->text.isEmpty()) { + bool ltr = groupBox->direction == Qt::LeftToRight; + QRect finalRect; + if (groupBox->subControls & QStyle::SC_GroupBoxCheckBox) { + finalRect = checkBoxRect.united(textRect); + finalRect.adjust(ltr ? -4 : -2, 0, ltr ? 2 : 4, 0); + } else { + finalRect = textRect; + finalRect.adjust(-2, 0, 2, 0); + } + region -= finalRect.adjusted(0, 0, 0, 3 - textRect.height() / 2); + } + painter->setClipRegion(region); proxy()->drawPrimitive(PE_FrameGroupBox, &frame, painter, widget); + painter->restore(); } // Draw title