summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Ehrlicher <[email protected]>2025-04-09 20:40:03 +0200
committerVolker Hilsheimer <[email protected]>2025-04-23 04:19:13 +0000
commit105ddadffeecf2370785ccd9bffde42fdbe25d1c (patch)
tree24bc8c2dedc40f79b1ce10a6d393e3a9f3c63439
parent3208ad494c7c03b964487787e246aedc444397dc (diff)
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 <[email protected]>
-rw-r--r--src/widgets/widgets/qdatetimeedit.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp
index ccfbc635dca..1c3118fe785 100644
--- a/src/widgets/widgets/qdatetimeedit.cpp
+++ b/src/widgets/widgets/qdatetimeedit.cpp
@@ -1092,15 +1092,15 @@ QSize QDateTimeEdit::sizeHint() const
w += 2; // cursor blinking space
QSize hint(w, h);
+ QStyleOptionSpinBox opt;
+ initStyleOption(&opt);
+ d->cachedSizeHint = style()->sizeFromContents(QStyle::CT_SpinBox, &opt, hint, this);
if (d->calendarPopupEnabled()) {
- QStyleOptionComboBox opt;
- opt.initFrom(this);
- opt.frame = d->frame;
- d->cachedSizeHint = style()->sizeFromContents(QStyle::CT_ComboBox, &opt, hint, this);
- } else {
- QStyleOptionSpinBox opt;
- initStyleOption(&opt);
- d->cachedSizeHint = style()->sizeFromContents(QStyle::CT_SpinBox, &opt, hint, this);
+ QStyleOptionComboBox optCbx;
+ optCbx.initFrom(this);
+ optCbx.frame = d->frame;
+ d->cachedSizeHint.rwidth() =
+ style()->sizeFromContents(QStyle::CT_ComboBox, &optCbx, hint, this).width();
}
d->cachedMinimumSizeHint = d->cachedSizeHint;