Important: Please read the Qt Code of Conduct -

How to zoom using mouse wheel using qt3d?

  • Hi All!

    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 =;
        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));
        // For camera controls
        Qt3DExtras::QOrbitCameraController *camController = new Qt3DExtras::QOrbitCameraController(sceneRoot);

    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.

  • 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().