Added first project implementation
This commit is contained in:
22
InteractiveChartView.cpp
Normal file
22
InteractiveChartView.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#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);
|
||||
}
|
||||
Reference in New Issue
Block a user