For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings


Need to speed up your development?
Have a look at our:

Samples & Tools


Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

ZoomIn and ZoomOut to cursor position?

codex's picture

this code work for zoomin and zoomout to center point

void Viewer3D::wheelEvent(QWheelEvent *event)
int numDegrees = event->delta() / 8;
int numSteps = numDegrees / 15;
myView->SetZoom(1 + numSteps * 0.1);

How make zoom to the mouse cursor position, like in AutoCAD?

Hans's picture

Use StartZoomAtPoint(X,Y) where X and Y are event->X() and event->Y() and then use ZoomAtPoint(X1,Y1, X2, Y1) where X1...Y1 are your Zooming-Factor.

codex's picture

thanks Hans, I found solution

void Viewer3D::wheelEvent(QWheelEvent *event)
QPoint p = event->pos();
myView->StartZoomAtPoint( p.x(), p.y() );
double delta = (double)( event->delta() ) / ( 15 * 8 );
int x = p.x();
int y = p.y();
int x1 = (int)( p.x() + width()*delta/100 );
int y1 = (int)( p.y() + height()*delta/100 );
myView->ZoomAtPoint( x, y, x1, y1 );