如何将 QDate 设置为当前日期?

Ann*_*rki 3 c++ qt4

我有一个Registration包含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) {}
Run Code Online (Sandbox Code Playgroud)

Ale*_*der 5

根据http://doc.qt.io/qt-5/qdatetime.html,您可以使用QDateTime::currentDateTime()来获取日期。

  • `注册::注册(人员a):m_Attendee(a),m_BookingDate(QDate::currentDate()){}` (3认同)