summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2016-08-04 16:41:12 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2016-09-27 11:21:53 +0000
commit3379ace11b30d8e9a2c9b45789561ac44bf29c06 (patch)
treeb3bd17041f33daa42656e259eeb903ef4c45eaa4 /src
parenta95d103bd2ed907b11c483c91e32139144828148 (diff)
QDateTimeEdit: synchronize time-spec before initializing display
QDateTimeEdit ignores the time-spec of its date-time value, using its own time-spec instead; mostly, this works because it first conforms the value to its own time-spec. However, during construction, before doing this, it set up its display data, which could leave it with a different time (rather than a different representation of the given time) than it was asked to use. Moved the updateTimeSpec() calls to immediately after setting value in QDateTimeEditPrivate::init() to ensure correct handling. Added test. Task-number: QTBUG-54781 Change-Id: I3b07c10997abb858fc0b40558bff96e3fdabbd83 Reviewed-by: Jesus Fernandez <jesus.fernandez@qt.io> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/widgets/qdatetimeedit.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp
index 960f84c13a..96a37197e9 100644
--- a/src/widgets/widgets/qdatetimeedit.cpp
+++ b/src/widgets/widgets/qdatetimeedit.cpp
@@ -2388,18 +2388,21 @@ void QDateTimeEditPrivate::init(const QVariant &var)
switch (var.type()) {
case QVariant::Date:
value = QDateTime(var.toDate(), QDATETIMEEDIT_TIME_MIN);
+ updateTimeSpec();
q->setDisplayFormat(defaultDateFormat);
if (sectionNodes.isEmpty()) // ### safeguard for broken locale
q->setDisplayFormat(QLatin1String("dd/MM/yyyy"));
break;
case QVariant::DateTime:
value = var;
+ updateTimeSpec();
q->setDisplayFormat(defaultDateTimeFormat);
if (sectionNodes.isEmpty()) // ### safeguard for broken locale
q->setDisplayFormat(QLatin1String("dd/MM/yyyy hh:mm:ss"));
break;
case QVariant::Time:
value = QDateTime(QDATETIMEEDIT_DATE_INITIAL, var.toTime());
+ updateTimeSpec();
q->setDisplayFormat(defaultTimeFormat);
if (sectionNodes.isEmpty()) // ### safeguard for broken locale
q->setDisplayFormat(QLatin1String("hh:mm:ss"));
@@ -2412,7 +2415,6 @@ void QDateTimeEditPrivate::init(const QVariant &var)
if (QApplication::keypadNavigationEnabled())
q->setCalendarPopup(true);
#endif
- updateTimeSpec();
q->setInputMethodHints(Qt::ImhPreferNumbers);
setLayoutItemMargins(QStyle::SE_DateTimeEditLayoutItem);
}