CameraItemView.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #pragma once
  2. #include <qgraphicsview.h>
  3. #include <qevent.h>
  4. class CameraItemView :
  5. public QGraphicsView
  6. {
  7. Q_OBJECT;
  8. public:
  9. //define a constructor
  10. CameraItemView(QWidget* parent = nullptr);
  11. //define a destructor
  12. ~CameraItemView();
  13. //define a function to achieve the mouse press event
  14. void mousePressEvent(QMouseEvent* event);
  15. //define a function to achieve the mouse release event
  16. void mouseReleaseEvent(QMouseEvent* event);
  17. //define a function to achieve the mouse move event
  18. void mouseMoveEvent(QMouseEvent* event);
  19. //define a function to achieve the mouse wheel event
  20. void wheelEvent(QWheelEvent* event);
  21. public:
  22. //define a Point to record the View Center Point
  23. //QPointF m_ViewCenterPoint;
  24. //define two float to record the View Scale
  25. float m_fViewScaleX;
  26. float m_fViewScaleY;
  27. //define a bool to indicate the mouse is pressed or not
  28. bool m_bMousePressed;
  29. //define a Point to record the mouse press point
  30. QPointF m_MousePressPoint;
  31. //define a Point to record the mouse move current point
  32. QPointF m_MouseMoveCurrentPoint;
  33. //define a point to record the view center point
  34. QPointF m_ViewCenterPoint;
  35. };