Compatibility Members for QTime

以下成員源於類 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 ().