windows compatible

This commit is contained in:
Guangzong 2022-06-10 20:21:11 -04:00
parent fc5eb437d0
commit cfd6706fa5

View File

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