Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to zoom using mouse wheel using qt3d?

How to zoom using mouse wheel using qt3d?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt3dqt 5.7qt3drenderqcamera
2 Posts 2 Posters 2.3k Views
  • 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.
  • P Offline
    P Offline
    Poorti
    wrote on 6 Sept 2016, 13:58 last edited by Poorti 9 Jun 2016, 13:59
    #1

    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
    0
    • M Offline
      M Offline
      m.sue
      wrote on 13 Sept 2016, 08:22 last edited by
      #2

      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
      1

      1/2

      6 Sept 2016, 13:58

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved