void ScreenshotsWidget::updateMouseShape(const QPoint &point) { switch(currentShotState){ case initShot: case beginShot: setCursor(Qt::CrossCursor); break; case beginMoveShot: setCursor(Qt::OpenHandCursor); break; case finishShot: case finishMoveShot: case finishControl: if(getSelectedRect().contains(point)) setCursor(Qt::OpenHandCursor); else updateMoveControlMouseShape(getMoveControlState(point)); break; case beginControl: updateMoveControlMouseShape(controlValue); //调用函数对移动8个控制点进行鼠标状态的改变 break; default: setCursor(Qt::ArrowCursor); break; } }
void ScreenshotsWidget::mousePressEvent(QMouseEvent *event) { //当开始进行拖动进行选择区域时,确定开始选取的beginPoint坐标 if(event->button() == Qt::LeftButton && currentShotState == initShot){ currentShotState = beginShot; //设置当前状态为beginShot状态 beginPoint = event->pos(); } //移动选区改变选区的所在位置 if(event->button() == Qt::LeftButton && isInSelectedRect(event->pos()) && getMoveControlState(event->pos()) == moveControl0){ currentShotState = beginMoveShot; //启用开始移动选取选项,beginMoveShot状态 moveBeginPoint = event->pos(); } //移动控制点改变选区大小 if(event->button() == Qt::LeftButton && getMoveControlState(event->pos()) != moveControl0){ currentShotState = beginControl; //开始移动控制点 controlValue = getMoveControlState(event->pos()); moveBeginPoint = event->pos(); } }
void WizScreenShotWidget::mousePressEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton && currentShotState == initShot) { currentShotState = beginShot; beginPoint = event->pos(); } if (event->button() == Qt::LeftButton && isInSelectedRect(event->pos()) && getMoveControlState(event->pos()) == moveControl0) { currentShotState = beginMoveShot; moveBeginPoint = event->pos(); } if (event->button() == Qt::LeftButton && getMoveControlState(event->pos()) != moveControl0) { currentShotState = beginControl; controlValue = getMoveControlState(event->pos()); moveBeginPoint = event->pos(); } }