How can I disable the automatic render in QVTKOpenGLNativeWidget

I want to make a timer that call render when I need (because I’m modify vtk data in another thread). But for now, the interactor in QVTKOpenGLNativeWidget will call render automatically. How can I avoid this?

I don’t think QVTKOpenGLNativeWidget does any rendering automatically. In our application (3D Slicer) we need to call RenderWindow->Render() from a rate-limited timer function to refresh the render window content. You could put a breakpoint in the Render() method and check what has called it.

Hi, following is the source code of QVTKOpenGLNativeWidget,you can see if user call setRenderWindow, it will create a default QVTKInteractor, and QVTKInteractor is inherit from vtkrenderWindowInteractor, so the QVTKInteractor will trigger render when user control his mouse. I want to disable this feature, that is, when user control his mouse, it just modify the camera parameter, and I will call render using a external timer.

void QVTKOpenGLNativeWidget::setRenderWindow(vtkGenericOpenGLRenderWindow* win)
{
  if (this->RenderWindow == win)
  {
    return;
  }

  // this will release all OpenGL resources associated with the old render
  // window, if any.
  if (this->RenderWindowAdapter)
  {
    this->makeCurrent();
    this->RenderWindowAdapter.reset(nullptr);
  }
  this->RenderWindow = win;
  if (this->RenderWindow)
  {
    this->RenderWindow->SetReadyForRendering(false);
    this->RenderWindow->SetFrameBlitModeToNoBlit();

    // if an interactor wasn't provided, we'll make one by default
    if (!this->RenderWindow->GetInteractor())
    {
      // create a default interactor
      vtkNew<QVTKInteractor> iren;
      // iren->SetUseTDx(this->UseTDx);
      this->RenderWindow->SetInteractor(iren);
      iren->Initialize();

      // now set the default style
      vtkNew<vtkInteractorStyleTrackballCamera> style;
      iren->SetInteractorStyle(style);
    }

    if (this->isValid())
    {
      // this typically means that the render window is being changed after the
      // QVTKOpenGLNativeWidget has initialized itself in a previous update
      // pass, so we emulate the steps to ensure that the new vtkRenderWindow is
      // brought to the same state (minus the actual render).
      this->makeCurrent();
      this->initializeGL();
      this->updateSize();
    }
  }
}

Maybe the default VTK render window interactor has some very simple mechanism for triggering rendering, which may be fine for sample applications but not for real work.

We use VTK render views provided by CTK library that has a smart timer mechanism that ensures that rendering happens quickly enough after it is requested, but not too frequently.