Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved How to zoom using mouse wheel using qt3d?

    General and Desktop
    qt3d qt 5.7 qt3drender qcamera
    2
    2
    1844
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Poorti
      Poorti last edited by Poorti

      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 = 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.

      1 Reply Last reply Reply Quote 0
      • m.sue
        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().

        1 Reply Last reply Reply Quote 1
        • First post
          Last post