#ifndef CALENDARDTEDIT_H #define CALENDARDTEDIT_H #include #include /* 需要设置这个属性,qss设置的图标才会生效 * setCalendarPopup(true); */ class CalendarDTEdit : public QDateTimeEdit { Q_OBJECT public: explicit CalendarDTEdit(QWidget *parent = nullptr); virtual ~CalendarDTEdit(); void SetCalendarAutoClose(bool value); void CloseCalendar(); /* 手动触发日期选择弹框 */ void triggerCalendarPopup(); /* 设置手动禁止修改日期区域,只能使用弹窗,第二个参数设置点击日期是否会出现日期选择弹框 */ void setManualDisableEdit(bool value, bool triggerPopup = false); signals: void sig_SetCurrentPage(int year, int month); protected: void mousePressEvent(QMouseEvent* e) override; bool eventFilter(QObject* watched, QEvent* event) override; private: QObject* m_pCalendar = nullptr; bool m_isPopup = false; }; #endif // CALENDARDTEDIT_H