add zoom action when wheel is spinning

This commit is contained in:
mpa 2014-06-11 11:06:57 +04:00
parent 874cf01c2a
commit fc81102714
2 changed files with 20 additions and 1 deletions

View File

@ -36,6 +36,7 @@
// Qt includes
#include <QApplication>
#include <QWidgetAction>
#include <QWheelEvent>
DependencyTree_View::DependencyTree_View( QWidget* theParent )
:GraphicsView_ViewPort( theParent ),
@ -156,6 +157,23 @@ void DependencyTree_View::mouseMoveEvent( QMouseEvent *event )
}
}
//=================================================================================
// function : wheelEvent()
// purpose : add zoom action when wheel is spinning
//=================================================================================
void DependencyTree_View::wheelEvent( QWheelEvent* event )
{
int inc = 10; // zoom coefficient
double cx = width() / 2;
double cy = height() / 2;
if( event->delta() > 0 )
zoom( cx, cy, cx + inc, cy + inc );
else
zoom( cx, cy, cx - inc, cy - inc );
QGraphicsView::wheelEvent( event );
}
//=================================================================================
// function : getViewName()
// purpose : return the name of current view

View File

@ -54,7 +54,8 @@ public:
void init( GraphicsView_ViewFrame* );
void updateModel( bool = true, bool = true );
void mouseMoveEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent* event);
void wheelEvent( QWheelEvent* event );
QString getViewName() const;
int getStudyId() const;