23 lines
665 B
C++
23 lines
665 B
C++
#include "InteractiveChartView.h"
|
|
|
|
void InteractiveChartView::wheelEvent(QWheelEvent* event)
|
|
{
|
|
qreal factor;
|
|
if (event->delta() > 0)
|
|
factor = 2.0;
|
|
else
|
|
factor = 0.5;
|
|
|
|
QRectF r = QRectF(chart()->plotArea().left(),
|
|
chart()->plotArea().top(),
|
|
chart()->plotArea().width() / factor,
|
|
chart()->plotArea().height() / factor);
|
|
QPointF mousePos = mapFromGlobal(QCursor::pos());
|
|
r.moveCenter(mousePos);
|
|
chart()->zoomIn(r);
|
|
QPointF delta = chart()->plotArea().center() - mousePos;
|
|
chart()->scroll(delta.x(), -delta.y());
|
|
|
|
QChartView::wheelEvent(event);
|
|
}
|