2012-02-22 82 views
2

我有一个Registration类,其中包括QDate成员。我如何将它初始化为当前日期?如何将QDate设置为当前日期?

#include <QDate> 

class Registration { 
private: 
    Person m_Attendee; 
    QDate m_BookingDate; // how do I initialze this? 
public: 
    Registration(Person a); 
}; 

Registration::Registration(Person a): m_Attendee(a) {} 

回答

4

http://doc.qt.io/qt-5/qdatetime.html,您可以使用QDateTime::currentDateTime()得到的日期。

+0

所以在registration.cpp我应该把常量QDate注册:: BookingDate = currentDateTime(); – 2012-02-22 08:46:11

+3

'登记注册::(一人):m_Attendee(一),m_BookingDate(QDATE ::的currentdate()){}' – Alexander 2012-02-22 09:01:25

+0

感谢ü非常 – 2012-02-22 09:12:51

相关问题