//鼠标移动范围
void ViewWidget::mouseMoveArea(QMouseEvent *event)
{
QPoint curpoint;
//若鼠标移动到该窗体的边界时进行判断
if(event->pos().x()>this->width()
|| event->pos().y() > this->height()
|| event->pos().x() < 0
|| event ->pos().y() < 0)
{
//限定范围使鼠标不从窗体左边越到右边
if(event->pos().x() < 0)
{
curpoint.setX(0);
curpoint.setY(event->pos().y());
QCursor::setPos(mapToGlobal(curpoint)) ;
}
//限定鼠标范围使鼠标不会从窗体上边穿越到下边
if(event->pos().y() < 0)
{
curpoint.setX(event->pos().x());
curpoint.setY(0);
QCursor::setPos(mapToGlobal(curpoint)) ;
}
}
}