#pragma once #include #include class CameraItemView : public QGraphicsView { Q_OBJECT; public: //define a constructor CameraItemView(QWidget* parent = nullptr); //define a destructor ~CameraItemView(); //define a function to achieve the mouse press event void mousePressEvent(QMouseEvent* event); //define a function to achieve the mouse release event void mouseReleaseEvent(QMouseEvent* event); //define a function to achieve the mouse move event void mouseMoveEvent(QMouseEvent* event); //define a function to achieve the mouse wheel event void wheelEvent(QWheelEvent* event); public: //define a Point to record the View Center Point //QPointF m_ViewCenterPoint; //define two float to record the View Scale float m_fViewScaleX; float m_fViewScaleY; //define a bool to indicate the mouse is pressed or not bool m_bMousePressed; //define a Point to record the mouse press point QPointF m_MousePressPoint; //define a Point to record the mouse move current point QPointF m_MouseMoveCurrentPoint; //define a point to record the view center point QPointF m_ViewCenterPoint; };