summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2020-09-21 15:58:35 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2020-10-26 11:41:50 +0000
commite655f9ce987e44484c94c20f404ca629d60d7686 (patch)
tree7efad3ca4ef3c156ea3be4f21b1e1800d12880f3 /src
parent1f2c756f8e493fff3c4708399149fa3c79dd9fad (diff)
Show the year correctly after it has been edited
When converting the year as an integer via the locale then it can add in group separators which would not be desired here. Therefore it should be converted via the QDate approach to get the right output for the year. Fixes: QTBUG-86307 Fixes: QTBUG-85966 Change-Id: I092bd1e5f69e544843fd5f28c96b94c9066490c5 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit d9edad81177954c89619b6dee70ca76f2f4709ef) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/widgets/qcalendarwidget.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp
index f9345d056c..bb64edd85d 100644
--- a/src/widgets/widgets/qcalendarwidget.cpp
+++ b/src/widgets/widgets/qcalendarwidget.cpp
@@ -1928,7 +1928,6 @@ void QCalendarWidgetPrivate::_q_nextMonthClicked()
void QCalendarWidgetPrivate::_q_yearEditingFinished()
{
Q_Q(QCalendarWidget);
- yearButton->setText(q->locale().toString(yearEdit->value()));
yearEdit->hide();
q->setFocusPolicy(oldFocusPolicy);
qApp->removeEventFilter(q);
@@ -1937,6 +1936,7 @@ void QCalendarWidgetPrivate::_q_yearEditingFinished()
QDate currentDate = getCurrentDate();
int newYear = q->locale().toInt(yearEdit->text());
currentDate = currentDate.addYears(newYear - currentDate.year(m_model->m_calendar), m_model->m_calendar);
+ yearButton->setText(q->locale().toString(currentDate, u"yyyy", m_model->m_calendar));
updateCurrentPage(currentDate);
}