QCommonStyle: sync CT_SpinBox with subControlRect()
The size calculation for CT_SpinBox was out-of-sync with the rects calculated in subControlRect() for SC_SpinBoxUp/Down. Fixes: QTBUG-115451 Change-Id: I140346fa1980e0cf95e0a07499f43467b721f01e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 60c665d0b320324affa76702b5e5de3d37117809) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
9493166694
commit
03ea1ebbe5
@ -5050,14 +5050,16 @@ QSize QCommonStyle::sizeFromContents(ContentsType contentsType, const QStyleOpti
|
|||||||
#if QT_CONFIG(spinbox)
|
#if QT_CONFIG(spinbox)
|
||||||
case CT_SpinBox:
|
case CT_SpinBox:
|
||||||
if (const auto *spinBoxOpt = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
|
if (const auto *spinBoxOpt = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
|
||||||
// Add button + frame widths
|
const int frameWidth = spinBoxOpt->frame
|
||||||
const qreal dpi = QStyleHelper::dpi(opt);
|
? proxy()->pixelMetric(PM_SpinBoxFrameWidth, spinBoxOpt, widget)
|
||||||
|
: 0;
|
||||||
|
size += QSize(2 * frameWidth, 2 * frameWidth);
|
||||||
const bool hasButtons = (spinBoxOpt->buttonSymbols != QAbstractSpinBox::NoButtons);
|
const bool hasButtons = (spinBoxOpt->buttonSymbols != QAbstractSpinBox::NoButtons);
|
||||||
const int buttonWidth = hasButtons ? qRound(QStyleHelper::dpiScaled(16, dpi)) : 0;
|
if (hasButtons) {
|
||||||
const int frameWidth = spinBoxOpt->frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth,
|
const auto height = qMax(8, size.height() / 2 - frameWidth);
|
||||||
spinBoxOpt, widget) : 0;
|
const auto buttonWidth = qMax(16, qMin(height * 8 / 5, size.width() / 3));
|
||||||
|
size.rwidth() += buttonWidth;
|
||||||
size += QSize(buttonWidth + 2 * frameWidth, 2 * frameWidth);
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user