paintEvent被重载绘画的问题?
1)假如paintEvent被重载,里头是空的,这个控件是变成透明的吗?
2)paintEvent被重载,为何要QPainter painter(this)才能绘画?
#include <QtGui/QWidget>enum eumScaleType{ SCALE_FIX = 0, SCALE_FREE = 1};enum eumMoveType{ DRAG_TOP_LEFT, DRAG_TOP_RIGHT, DRAG_BOTTOM_LEFT, DRAG_BOTTOM_RIGHT, DRAG_LEFTMIDDLE, DRAG_RIGHTMIDDLE, DRAG_TOPMIDDLE, DRAG_BOTTOMMIDDLE, DRAG_CENTER, NO_ACTION};class editPainter : public QWidget{ Q_OBJECTpublic: editPainter(QWidget* pParent=0); void setImagePath(QString strPath); void setScaleType(eumScaleType scaleType);protected: virtual void paintEvent(QPaintEvent * event); //重载 virtual void mousePressEvent(QMouseEvent *event); //重载 virtual void mouseMoveEvent(QMouseEvent *event); //重载 virtual void mouseReleaseEvent(QMouseEvent *event); //重载private: void prePaintRect(); void capturePixmap(); void calculatePaintRect(QMouseEvent *event, eumMoveType enAction); void calculateMiniRect();private: QPixmap *m_pPixmapSource; //源图 QPixmap *m_pPixmapCaptured; //扑捉图 QRect m_rcPixmapSource; //源图尺寸 QRect m_rcPixmapTarget; //目的图尺寸 QRect m_rectOfRedLine; //选取框尺寸 bool m_bMousePressed; //鼠标按下 bool m_bDisChangeDir; //不许变更方向 QPoint m_ptLast; //上一次鼠标位置 //矩形小方框 QRect m_rcTopLeft; QRect m_rcTopRight; QRect m_rcBottomLeft; QRect m_rcBottomRight; QRect m_rcLeftMiddle; QRect m_rcRightMiddle; QRect m_rcTopMiddle; QRect m_rcBottomMiddle; eumMoveType m_enAction; //拖动方向 eumScaleType m_eumScaleType; //比例模式signals: void signalPixmapChange(QPixmap *pixmap); //截取图片发生变化};