widget.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #ifndef WIDGET_H
  2. #define WIDGET_H
  3. #include <QWidget>
  4. #include "udphelper.h"
  5. #include "volviewform.h"
  6. #include <QList>
  7. #include <QLabel>
  8. #include <QGraphicsProxyWidget>
  9. #include <QGraphicsView>
  10. #include <QTimer>
  11. namespace Ui {
  12. class Widget;
  13. }
  14. //ST7735驱动
  15. #define ST7735_ERROR
  16. #define JY242 //景园2.42寸屏幕
  17. #ifdef ST7735_ERROR
  18. //ST7735 驱动使用GRB红色与蓝色位置相反
  19. #define LABEL_RED "QLabel{color: blue;}"
  20. #define LABEL_GREEN "QLabel{color: rgb(255, 255, 255);}"
  21. #define LABEL_SELECT "background-color:blue;color: white;"
  22. #define LABEL_Defalut "background-color:rgb(0, 0, 0);color: white;"
  23. #else
  24. #define LABEL_RED "QLabel{color: red;}"
  25. #define LABEL_GREEN "QLabel{color: rgb(115, 210, 22);}"
  26. #define LABEL_SELECT "background-color:rgb(115, 210, 22);color: white;"
  27. #define LABEL_Defalut "background-color:rgb(85, 87, 83);color: rgb(115, 210, 22);"
  28. #endif
  29. class Widget : public QWidget
  30. {
  31. Q_OBJECT
  32. public:
  33. explicit Widget(QWidget *parent = 0);
  34. ~Widget();
  35. void setInitData(QGraphicsProxyWidget* pAngleCtrl, QGraphicsView* pView, int nWidget,int nHight);
  36. //是否显示详细数据
  37. int getShowModeIndex();
  38. int getShowPagIndex();
  39. int getShowSubIndex();
  40. int getShowPHIndex();
  41. void setShowPHIndex(int nIndex);
  42. //更新日期IP
  43. void UpdateDate();
  44. QString ReadIP();
  45. void SetData(QLabel* pLab,QString strShow);
  46. void SetV(QString strShow);
  47. void SetA(QString strShow);
  48. void SetW(QString strShow);
  49. void SetF(QString strShow);
  50. void SetSUM(QString strShow);
  51. void SetIP(QString strIP);
  52. void SetT(QString strShow);
  53. void SetH(QString strShow);
  54. void setCH(int nIndex);
  55. void setPH(int nIndex,int nPhID);
  56. void SetStatus(QString strShow);
  57. //点击事件
  58. //void BtnDown(int nButtonID,int nDownType);
  59. //上翻页
  60. void pageUp();
  61. //下翻页
  62. void pageDown();
  63. //切换页面
  64. void ChangeView(int widgetType,int nIndex);
  65. //modbus设置
  66. void setSelectStatus(int nIndex);
  67. void CtrlBtnSet(int nIndex,int nData);
  68. int nMAXChildIndex;
  69. private slots:
  70. void slot_TimerRun();
  71. public:
  72. Ui::Widget *ui;
  73. private:
  74. UdpHelper* udpHelper;
  75. int device_type ;
  76. int device_chn ;
  77. QList<VolViewForm*> volView;
  78. //当前显示页面ID
  79. int nChidIndex;
  80. int nChidPHIndex;
  81. int m_nAngle;
  82. QGraphicsProxyWidget* m_pAngleCtrl;
  83. QGraphicsView* m_pView;
  84. int m_nWidth;
  85. int m_nHeight;
  86. QTimer* m_Timer;
  87. };
  88. #endif // WIDGET_H