以下成员源于类 QTime are part of the Qt compatibility layer. We advise against using them in new code.
| QTime | currentTime (Qt::TimeSpec specification ) |
[static]
QTime
QTime::
currentTime
(
Qt::TimeSpec
specification
)
Returns the current time for the given specification .
To replace uses of this function where the specification is Qt::LocalTime , use the currentDate() overload that takes no parameters instead; otherwise, use QDateTime::currentDateTime () and convert the result to a UTC measurement.
例如,若有代码像
QTime localTime = QTime::currentTime(Qt::LocalTime); QTime utcTime = QTime::currentTime(Qt::UTC);
可以把它重写成
QTime localTime = QTime::currentTime(); QTime utcTime = QTimeTime::currentDateTime().toUTC().time();
另请参阅 QDateTime::toUTC ().