Interactor and callback: VTK 9.1 + QtQuick


I have a simple GUI with VTK+QT that would update the volume constantly. We use it to have 3D live volume rendering.

I am trying to do the same thing with a QtQuick GUI, I faced two issues:
1- The timer callback that I use for updating the Data, will not work until I move the cursor over the render window.
2- When I click on the render window, it crashes.

Here’s what I get in the output after it crashes:

Generic Warning: In …\VTK-9.1.0\Source\Rendering\OpenGL2\vtkOpenGLState.cxx, line 539
at stack loc
at vtksys::SystemInformation::GetProgramStack
at vtksys::SystemInformation::GetProgramStack
at vtkOpenGLState::vtkglDrawBuffer
at vtkOpenGLRenderWindow::BlitDisplayFramebuffersToHardware
at vtkOpenGLRenderWindow::Frame
at vtkGenericOpenGLRenderWindow::Frame
at vtkRenderWindow::Render
at vtkOpenGLRenderWindow::Render
at vtkGenericOpenGLRenderWindow::Render
at vtkRenderWindowInteractor::Render
at QQuickVTKRenderWindow::paint
at QMetaObject::activate
at QQuickWindowPrivate::renderSceneGraph
at QSGDefaultLayer::updateTexture
at QSGDefaultLayer::updateTexture
at QThread::start
at BaseThreadInitThunk
at RtlUserThreadStart

Part of the code the code with the callback, as I am suspecting what I do with vtkRenderWindowInteractor (iren) is not right probably for QML case:

m_QQuickvtkrenderItem->renderer()->SetBackground(0.10, 0.10, 0.10);

vtkSmartPointer<vtkTimerCallback> cb = vtkSmartPointer<vtkTimerCallback>::New();
iren = m_QQuickvtkrenderItem->renderer()->GetRenderWindow()->GetInteractor();

cb->IREN = iren;
cb->IMData = ImData;
cb->Height = height;
cb->Width = width;
cb->Depth = depth;
cb->Nframes = n_frames;
cb->Data = data;
iren->AddObserver(vtkCommand::TimerEvent, cb);
int timerId = iren->CreateRepeatingTimer(0.005);

Any help would be much appreciated.


I managed to solve the two issue above. Just writing it down here in case someone else is facing the same issue.

For issue number 1: in order to have the volume update all the time, not only when the mouse is over the vtk window (Hover). In the callback function I update the QQuickWindow:

For issue number 2: Instead of using vtk timer and vtk interactor, I used Qtimer and update the volume data in the Qtimer’s callback function.