From fc96ce3a2b4b669dd69df59e618a951537804c27 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sun, 3 Nov 2024 10:48:10 +0100 Subject: [PATCH] QDateTimeEdit: use correct size hint when calendarPopup is enabled When calendarPopup is enabled, a QComboBox instead a QSpinBox is drawn but the size hint for QSpinBox was used which resulted in a too small width for the widget (depending on the underlying style). Therefore use the size hint for CT_ComboBox in this case as it was already done for mac. Fixes: QTBUG-11967 Change-Id: I817bdc99ae5d1189b9f0451a857022abe64b3bf8 Reviewed-by: Volker Hilsheimer (cherry picked from commit 0a1c1711453697a88eee7fdb6f4cf082bfd433e2) Reviewed-by: Qt Cherry-pick Bot --- src/widgets/widgets/qdatetimeedit.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index efc6e327da..95c174e971 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -1092,14 +1092,12 @@ QSize QDateTimeEdit::sizeHint() const w += 2; // cursor blinking space QSize hint(w, h); - -#ifdef Q_OS_MAC if (d->calendarPopupEnabled()) { QStyleOptionComboBox opt; + opt.initFrom(this); + opt.frame = d->frame; d->cachedSizeHint = style()->sizeFromContents(QStyle::CT_ComboBox, &opt, hint, this); - } else -#endif - { + } else { QStyleOptionSpinBox opt; initStyleOption(&opt); d->cachedSizeHint = style()->sizeFromContents(QStyle::CT_SpinBox, &opt, hint, this);