widget.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 "msgwidget.h"
  11. namespace Ui {
  12. class Widget;
  13. }
  14. //ST7735驱动
  15. #define ST7735_ERROR
  16. #ifdef ST7735_ERROR
  17. //ST7735 驱动使用GRB红色与蓝色位置相反
  18. #define LABEL_RED "QLabel{color: blue;}"
  19. #define LABEL_GREEN "QLabel{color: rgb(115, 210, 22);}"
  20. #define LABEL_SELECT "background-color:rgb(115, 210, 22);color: white;"
  21. #define LABEL_Defalut "background-color:rgb(85, 87, 83);color: rgb(115, 210, 22);"
  22. #else
  23. #define LABEL_RED "QLabel{color: red;}"
  24. #define LABEL_GREEN "QLabel{color: rgb(115, 210, 22);}"
  25. #define LABEL_SELECT "background-color:rgb(115, 210, 22);color: white;"
  26. #define LABEL_Defalut "background-color:rgb(85, 87, 83);color: rgb(115, 210, 22);"
  27. #endif
  28. class Widget : public QWidget
  29. {
  30. Q_OBJECT
  31. public:
  32. explicit Widget(QWidget *parent = 0);
  33. ~Widget();
  34. void setInitData(QGraphicsProxyWidget* pAngleCtrl, QGraphicsView* pView, int nWidget,int nHight);
  35. //是否显示详细数据
  36. int getShowModeIndex();
  37. int getShowPagIndex();
  38. int getShowSubIndex();
  39. int getShowPHIndex();
  40. void setShowPHIndex(int nIndex);
  41. //更新日期IP
  42. void UpdateDate();
  43. QString ReadIP();
  44. void SetV(QString strShow);
  45. void SetA(QString strShow);
  46. void SetW(QString strShow);
  47. void SetF(QString strShow);
  48. void SetSUM(QString strShow);
  49. void SetIP(QString strIP);
  50. void SetT(QString strShow);
  51. void SetH(QString strShow);
  52. void SetCO2(QString strShow);
  53. void SetVer(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. void setMAXChildIndex(int nIndex);
  69. int nMAXChildIndex;
  70. //是否显示MSG
  71. bool isHiddenMSGWidget(){
  72. if(m_pMSGWidget)
  73. return m_pMSGWidget->isHidden();
  74. return false;
  75. }
  76. //点击任意按钮确认
  77. void ClickMSGBtn();
  78. //
  79. void adjustMSGWidgetPosition(bool isAuto=true);
  80. //设置显示方式
  81. void setMonwayType(int nType);
  82. protected:
  83. void resizeEvent(QResizeEvent *event) override;
  84. signals:
  85. void signal_ClickMSG();//报警确认
  86. void signal_SetData(QLabel* pLab,QString strShow);
  87. public slots:
  88. //改为异步刷新数据
  89. void SetData(QLabel* pLab,QString strShow);
  90. //显示msg窗口
  91. void ShowMSGWidget(QString strShowData);
  92. public:
  93. Ui::Widget *ui;
  94. private:
  95. UdpHelper* udpHelper;
  96. int device_type ;
  97. int device_chn ;
  98. //QList<VolViewForm*> volView;
  99. //当前显示页面ID
  100. int nChidIndex;
  101. int nChidPHIndex;
  102. QGraphicsProxyWidget* m_pAngleCtrl;
  103. QGraphicsView* m_pView;
  104. int m_nWidth;
  105. int m_nHeight;
  106. MSGWidget* m_pMSGWidget;//提示界面
  107. int nIndexShow;
  108. public:
  109. int m_nAngle;
  110. int m_nMonwayType;//1:总检测 2:分监分控 3:分监不控
  111. };
  112. #endif // WIDGET_H