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

标签 c++ qt4

我有一个包含 QDate 成员的 Registration 类。如何将其初始化为当前日期?

#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) {}

最佳答案

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

关于c++ - 如何将 QDate 设置为当前日期?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9391255/

相关文章:

c++ - Scanf 使用\n。不知道它有什么作用

c++ - 有谁知道如何使用 qt creator 调试子进程?

qt - 如何删除小部件上已经存在的布局?

drop-down-menu - 在 Qt 中创建自定义上下文菜单

c++ - 假设任何 x86 编译的应用程序总是在 x64 版本下运行是否安全?

c++ - DebugBreak 不中断

c++ - 在行尾之前查找最后一个值

qt - PyQt4:为 QLineEdit 结合 textChanged 和 editFinished

c++ - 从非 ui 类到 Qt UI 的回调函数

macos - Qt 4.8 - 在 mac-mini (OS X Lion) 上检测 SD 卡的插入和移除