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.7 6.6
Change-Id: I3daf5854195e28a5ee3cb50343e2dd56e66ed940
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
This commit is contained in:
Ghenady Kuznetsov 2024-01-01 19:25:20 +02:00
parent 6a921b6751
commit 9b4c35abff

View File

@ -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