diff --git a/plotview.cpp b/plotview.cpp index 6dd1bab..f2c4a62 100644 --- a/plotview.cpp +++ b/plotview.cpp @@ -18,6 +18,7 @@ */ #include "plotview.h" +#include #include #include #include @@ -107,6 +108,22 @@ void PlotView::enableCursors(bool enabled) viewport()->update(); } +bool PlotView::eventFilter(QObject * obj, QEvent *event) +{ + if (event->type() == QEvent::Wheel) { + QWheelEvent *wheelEvent = (QWheelEvent*)event; + if (QApplication::keyboardModifiers() & Qt::ControlModifier) { + if (wheelEvent->angleDelta().y() > 0) { + emit zoomIn(); + } else if (wheelEvent->angleDelta().y() < 0) { + emit zoomOut(); + } + return true; + } + } + return false; +} + void PlotView::invalidateEvent() { horizontalScrollBar()->setMinimum(0); diff --git a/plotview.h b/plotview.h index 5e9e6bd..6c97476 100644 --- a/plotview.h +++ b/plotview.h @@ -51,6 +51,7 @@ public slots: void setPowerMax(int power); protected: + bool eventFilter(QObject * obj, QEvent *event) override; void paintEvent(QPaintEvent *event); void resizeEvent(QResizeEvent * event); void scrollContentsBy(int dx, int dy);