各位大佬.
Hello, My Gods.
我的问题是酱婶儿滴.
This problem is about Qt event.
在QScrollArea中显示图片时,其默认有一个鼠标滚轮控制垂直滚动条滚动的事件。所以当我想重写wheelEvent事件之后,它总是会在滚动条滚到头的时候才实现图像的缩放操作,所以怎样才能控制让滚轮操作只影响图像缩放,不影响垂直滚轮嘞?
下面是wheelEvent的代码.
private slots:
// Reimplement the wheelEvent() to Achieve Zoom in and Zoom out.
void wheelEvent(QWheelEvent *e);
/**
* @BRIEF Reimplement wheelEvent()
* @param QWheelEvent: Event about mouse wheel
*/
void MatchWindowSingle::wheelEvent(QWheelEvent *e)
{
// If numDegress > 0, then zoom in,
// else, zoom out.
// The scale control the picture's size.
int numDegress = e->delta();
// Update ScrollArea 控制图片缩放的各个函数
if (ui.sa_geoImage->hasFocus()){
identityScaleFactor(&numDegress, &scaleFactor_MIN_g, &scaleFactor_g);
updateScrollArea(&geoPic, ui.sa_geoImage, &geoImageLable, &scaleFactor_g);
}else if (ui.sa_videoImage->hasFocus()){
identityScaleFactor(&numDegress, &scaleFactor_MIN_v, &scaleFactor_v);
updateScrollArea(&videoPic, ui.sa_videoImage, &videoImageLable, &scaleFactor_v);
}
}