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. Send QKeyEvent to QOrbitCameraController

Send QKeyEvent to QOrbitCameraController

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 249 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.
  • A Offline
    A Offline
    AdamOwsley
    wrote on last edited by
    #1

    I'm using QOrbitCameraController as the camera controller for displaying a QMesh. QOrbitCameraController allows users to press the escape key in order to display all of the mesh inside of its viewing window. In my case, this is a QWidget created from a Qt3DWindow.

    Is there a way to send an escape key event to the camera controller so that it displays the initial view just as if the escape key had been pressed. I've tried postEvent and sendEvent, but there is no change in the view of the mesh. Anyone have any clues?

    Qt3DExtras::QOrbitCameraController *cameraController = new Qt3DExtras::QOrbitCameraController(rootScene);
    QCoreApplication::postEvent(cameraController, new QKeyEvent(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier));
    
    1 Reply Last reply
    0
    • A Offline
      A Offline
      AdamOwsley
      wrote on last edited by
      #3

      Thanks for your input. I did not see anything in the QOrbitCameraController hierarchy that provided any clues related to the QKeyEvent; however, it seems that I overlooked the obvious as I drove straight into the weeds. QCamera provides the capability to view the entire model via its viewAll() method. The code snippet follows.

      Qt3DExtras::Qt3DWindow *view3DWindow = new Qt3DExtras::Qt3DWindow();
      view3DWindow->setRootEntity(rootScene);
      QWidget *view3DWidget = QWidget::createWindowContainer(view3DWindow);
      Qt3DRender::QCamera *camera = view3DWindow->camera();
      Qt3DExtras::QOrbitCameraController *cameraController = new Qt3DExtras::QOrbitCameraController(rootScene);
      cameraController->setCamera(camera);
      view3DWidget->show();
      camera->viewAll();
      
      1 Reply Last reply
      0
      • Kent-DorfmanK Offline
        Kent-DorfmanK Offline
        Kent-Dorfman
        wrote on last edited by
        #2

        I think you are on the right path here, but as just a WAG, perhaps the key event handler within QOrbitCamerController is in a subclass there-of, and not being directly interpretted by the main class. That would be my guess as to the reason passing the key event is ignored.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          AdamOwsley
          wrote on last edited by
          #3

          Thanks for your input. I did not see anything in the QOrbitCameraController hierarchy that provided any clues related to the QKeyEvent; however, it seems that I overlooked the obvious as I drove straight into the weeds. QCamera provides the capability to view the entire model via its viewAll() method. The code snippet follows.

          Qt3DExtras::Qt3DWindow *view3DWindow = new Qt3DExtras::Qt3DWindow();
          view3DWindow->setRootEntity(rootScene);
          QWidget *view3DWidget = QWidget::createWindowContainer(view3DWindow);
          Qt3DRender::QCamera *camera = view3DWindow->camera();
          Qt3DExtras::QOrbitCameraController *cameraController = new Qt3DExtras::QOrbitCameraController(rootScene);
          cameraController->setCamera(camera);
          view3DWidget->show();
          camera->viewAll();
          
          1 Reply Last reply
          0

          • Login

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