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 () 代替。