How to zoom using mouse wheel using qt3d?
Poorti last edited by Poorti
I have created a sample to load 3d models. I am able to load the model.
I have used QOrbitCameraController.
Here is the code,
// Scene Camera Qt3DRender::QCamera *camera = view.camera(); camera->setProjectionType(Qt3DRender::QCameraLens::PerspectiveProjection); camera->setAspectRatio(view.width() / view.height()); camera->setUpVector(QVector3D(0.0f, 1.0f, 0.0f)); camera->setViewCenter(QVector3D(0.04f, 1.0f, 0.0f)); camera->setPosition(QVector3D(0.0f, 2.5f, 2.1f)); camera->setNearPlane(0.001f); camera->setFarPlane(100.0f); // For camera controls Qt3DExtras::QOrbitCameraController *camController = new Qt3DExtras::QOrbitCameraController(sceneRoot); camController->setCamera(camera);
I see that zoom-in/out is done by pressing both mouse buttons and dragging.
How can I change it so that zooming is done by moving the mouse wheel?
I am using qt 5.7 on windows.
m.sue last edited by
With the techniques used in QOrbitCameraController you cannot yet handle wheel events. This will be implemented in Qt 5.8 AFAIK.
If you want to have something now you will have to implement it the old fashoined way i.e. override the virtual function void Qt3DWindow::wheelEvent(QWheelEvent *ev) and there change the field of view of the camera().