diff --git a/GChartView.cpp b/GChartView.cpp index db59013..f31b773 100644 --- a/GChartView.cpp +++ b/GChartView.cpp @@ -31,7 +31,6 @@ GChartView::~GChartView() { } void GChartView::wheelEvent(QWheelEvent *event) { - auto pixels = event->pixelDelta(); auto degrees = event->angleDelta(); auto cursor_y = event->position().y(); auto cur_range_max = axis_y->max(); @@ -45,7 +44,7 @@ void GChartView::wheelEvent(QWheelEvent *event) { if (cursor_y < pos_max && cursor_y > pos_min) { center = chart->mapToValue(QPointF(0, cursor_y)).y(); auto cur_range = (cur_range_max - cur_range_min); - if (pixels.y() > 0) + if (degrees.y() > 0) new_range = cur_range * 0.8; else new_range = cur_range / 0.8; @@ -59,12 +58,12 @@ void GChartView::wheelEvent(QWheelEvent *event) { } if (new_min < -2.5) { new_max += (-2.5 - new_min); - new_min = 2.5; + new_min = -2.5; new_max = new_max > 2.5 ? 2.5 : new_max; } axis_y->setRange(new_min, new_max); - qDebug() << new_min << " " << new_max; + qDebug() << "new_min: " << new_min << " " << new_max; }