Skip to content

Commit

Permalink
QDateTimeEdit: use correct size hint when calendarPopup is enabled
Browse files Browse the repository at this point in the history
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 <volker.hilsheimer@qt.io>
(cherry picked from commit 0a1c171)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
  • Loading branch information
chehrlic authored and Qt Cherry-pick Bot committed Nov 7, 2024
1 parent 590ac5b commit fc96ce3
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/widgets/widgets/qdatetimeedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit fc96ce3

Please sign in to comment.