Compatibility Members for QDate

以下成員源於類 QDate are part of the Qt compatibility layer. We advise against using them in new code.

靜態公共成員

QDate currentDate (Qt::TimeSpec spec )
QString dayName (int weekday )
bool leapYear (int year )
QString monthName (int month )

成員函數文檔編製

[static] QDate QDate:: currentDate ( Qt::TimeSpec spec )

spec is Qt::LocalTime ,使用 currentDate () overload that takes no parameters instead; otherwise, use QDateTime::currentDateTime ().

例如,若有代碼像

QDate localDate = QDate::currentDate(Qt::LocalTime);
QDate utcDate = QDate::currentDate(Qt::UTC);
					

可以把它重寫成

QDate localDate = QDate::currentDate();
QDate utcDate = QDateTime::currentDateTime().toUTC().date();
					

另請參閱 QDateTime::toUTC ().

[static] QString QDate:: dayName ( int weekday )

使用 shortDayName () 代替。

[static] bool QDate:: leapYear ( int year )

使用 isLeapYear () 代替。

[static] QString QDate:: monthName ( int month )

使用 shortMonthName () 代替。