timepartwidget.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef TIMEPARTWIDGET_H
  2. #define TIMEPARTWIDGET_H
  3. #include <QWidget>
  4. class MyTimeDelegate;
  5. class QListWidgetItem;
  6. class QScrollBar;
  7. namespace Ui {
  8. class TimePartWidget;
  9. }
  10. class TimePartWidget : public QWidget
  11. {
  12. Q_OBJECT
  13. public:
  14. enum emSection {
  15. HOUR = 0,
  16. MINUTE = 1,
  17. SECOND = 2,
  18. MAX_SECTION
  19. };
  20. public:
  21. explicit TimePartWidget(QWidget *parent = nullptr);
  22. TimePartWidget(emSection type, QWidget* parent = nullptr);
  23. ~TimePartWidget();
  24. emSection GetType() const {return m_type;}
  25. void SetTime(const QDateTime& dt);
  26. void SetMaxWidth(int w);
  27. void ScrollToSelect();
  28. /* 设置QSS */
  29. void setQSS();
  30. protected:
  31. void enterEvent(QEvent* event) override;
  32. void leaveEvent(QEvent* event) override;
  33. signals:
  34. void sigItemClicked(QListWidgetItem* item);
  35. private:
  36. void InitListWidget(int total);
  37. void SelectListItem(int time);
  38. private:
  39. Ui::TimePartWidget *ui;
  40. emSection m_type;
  41. QScopedPointer<MyTimeDelegate> m_delegate;
  42. QScopedPointer<QScrollBar> m_pListBar;
  43. };
  44. #endif // TIMEPARTWIDGET_H