发生了奇怪的事情:我需要在标签上使用橡皮筋。这是我的代码:
QRubberBand *rubberBand;
QPoint mypoint;
void MainWindow::mousePressEvent(QMouseEvent *event){
mypoint = event->pos();
rubberBand = new QRubberBand(QRubberBand::Rectangle, ui->label_2);//new rectangle band
rubberBand->setGeometry(QRect(mypoint, ui->label_2->size()));
rubberBand->show();
}
void MainWindow::mouseMoveEvent(QMouseEvent *event){
rubberBand->setGeometry(QRect(mypoint, event->pos()).normalized());//Area Bounding
}
void MainWindow::mouseReleaseEvent(QMouseEvent *event){
rubberBand->hide();// hide on mouse Release
rubberBand->clearMask();
}
一切正常,但只有一个问题 - RubberBound 开始画得比游标设置的 100-150 像素低一点。
我究竟做错了什么 ?