calendardtedit.h 987 B

1234567891011121314151617181920212223242526272829303132333435
  1. #ifndef CALENDARDTEDIT_H
  2. #define CALENDARDTEDIT_H
  3. #include <QWidget>
  4. #include <QDateTimeEdit>
  5. /* 需要设置这个属性,qss设置的图标才会生效
  6. * setCalendarPopup(true);
  7. */
  8. class CalendarDTEdit : public QDateTimeEdit
  9. {
  10. Q_OBJECT
  11. public:
  12. explicit CalendarDTEdit(QWidget *parent = nullptr);
  13. virtual ~CalendarDTEdit();
  14. void SetCalendarAutoClose(bool value);
  15. void CloseCalendar();
  16. /* 手动触发日期选择弹框 */
  17. void triggerCalendarPopup();
  18. /* 设置手动禁止修改日期区域,只能使用弹窗,第二个参数设置点击日期是否会出现日期选择弹框 */
  19. void setManualDisableEdit(bool value, bool triggerPopup = false);
  20. signals:
  21. void sig_SetCurrentPage(int year, int month);
  22. protected:
  23. void mousePressEvent(QMouseEvent* e) override;
  24. bool eventFilter(QObject* watched, QEvent* event) override;
  25. private:
  26. QObject* m_pCalendar = nullptr;
  27. bool m_isPopup = false;
  28. };
  29. #endif // CALENDARDTEDIT_H