I'm trying to use a QTimeEdit widget for UTC time. After creating the widget, I call QTimeEdit::setTimeSpec(Qt::UTC). When the widget is displayed, the time is locked at 08:00:00. I can't change the time (I'm in the US Pacific time zone). If I don't set the TimeSpec, the widget works, but offsets programmatically entered times by the local difference from GMT. Is there a bug in QTimeEdit or more likely, am I missing something in setting up the QEditTime widget?
Code snippet creating widget:
Code:
mpDate->setTimeSpec(Qt::UTC); mpDate->setCalendarPopup(true); mpTime->setTimeSpec(Qt::UTC); mpTime->setDisplayFormat("HH:mm:ss");
Method setting the time:
Code:
void DataCollectionWidget::setCollectionTime(const time_t& time) { QDateTime dateTime; dateTime.setTimeSpec(Qt::UTC); dateTime.setTime_t(time); if (dateTime.isValid()) { mpDate->setDate(dateTime.date()); mpTime->setTime(dateTime.time()); } }
The QDateEdit widget seems to work fine with the call to setTimeSpec(Qt::UTC), just the QTimeEdit widget is locked. QTimeEdit also locks up for Qt::OffsetFromUTC, but works fine (except I don't want the local time zone offset) for Qt::LocalTime.
Dick