QDateTimeEdit: Unify height of QDateTimeEdit

After 0a1c1711453697a88eee7fdb6f4cf082bfd433e2 a QDateTimeEdit with and
without a popup has different heights in some styles. Fixing the styles
may break existing layouts so we only get the needed width when the
popup is enable from CT_ComboBox and let the height being calculated
by CT_SpinBox to make sure both variants have the same height.

Pick-to: 6.9 6.8
Fixes: QTBUG-135029
Task-number: QTBUG-11967
Change-Id: I01c6f598d34a0b73125e60650c61a84b27d79ac8
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Christian Ehrlicher 2025-04-09 20:40:03 +02:00 committed by Volker Hilsheimer
parent 3208ad494c
commit 105ddadffe

View File

@ -1092,15 +1092,15 @@ QSize QDateTimeEdit::sizeHint() const
w += 2; // cursor blinking space w += 2; // cursor blinking space
QSize hint(w, h); QSize hint(w, h);
QStyleOptionSpinBox opt;
initStyleOption(&opt);
d->cachedSizeHint = style()->sizeFromContents(QStyle::CT_SpinBox, &opt, hint, this);
if (d->calendarPopupEnabled()) { if (d->calendarPopupEnabled()) {
QStyleOptionComboBox opt; QStyleOptionComboBox optCbx;
opt.initFrom(this); optCbx.initFrom(this);
opt.frame = d->frame; optCbx.frame = d->frame;
d->cachedSizeHint = style()->sizeFromContents(QStyle::CT_ComboBox, &opt, hint, this); d->cachedSizeHint.rwidth() =
} else { style()->sizeFromContents(QStyle::CT_ComboBox, &optCbx, hint, this).width();
QStyleOptionSpinBox opt;
initStyleOption(&opt);
d->cachedSizeHint = style()->sizeFromContents(QStyle::CT_SpinBox, &opt, hint, this);
} }
d->cachedMinimumSizeHint = d->cachedSizeHint; d->cachedMinimumSizeHint = d->cachedSizeHint;