mirror of
https://github.com/miek/inspectrum.git
synced 2026-03-03 06:54:17 +01:00
plotview: Zoom in/out on ctrl + mouse wheel
This commit is contained in:
17
plotview.cpp
17
plotview.cpp
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user