plotview: Zoom in/out on ctrl + mouse wheel

This commit is contained in:
Mike Walters
2016-03-10 01:57:23 +00:00
parent d35e24be37
commit aeffd64f97
2 changed files with 18 additions and 0 deletions

View File

@@ -18,6 +18,7 @@
*/
#include "plotview.h"
#include <QApplication>
#include <QDebug>
#include <QPainter>
#include <QScrollBar>
@@ -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);