# vtk-9 with QML - examples?

**URL:** https://discourse.vtk.org/t/vtk-9-with-qml-examples/9347
**Category:** Support
**Created:** [September 14, 2022, 6:03pm UTC](https://discourse.vtk.org/t/vtk-9-with-qml-examples/9347 "2022-09-14T18:03:13Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Tomasso](https://discourse.vtk.org/user_avatar/discourse.vtk.org/tomasso/32/5786_2.png) [@Tomasso](https://discourse.vtk.org/u/Tomasso)
#### Post date: [September 14, 2022, 6:03pm UTC](https://discourse.vtk.org/t/vtk-9-with-qml-examples/9347/1 "2022-09-14T18:03:13Z")

</div>

I wrote an application that defines user controls with QML (Qt-5.14), and displays polygonal surface data with VTK-8.2. My software uses [the approach described here](https://www.qt.io/blog/2015/05/11/integrating-custom-opengl-rendering-with-qt-quick-via-qquickframebufferobject), extending QQuickFrameBufferObject which runs in the main thread, and QQuickFrameBufferObject::Renderer, which runs in the render thread. I need to upgrade to vtk-9, but unfortunately my application no longer displays the surface data when built with vtk-9.0. Specifically when my renderer calls vtkGenericOpenGLRendererWindow::Render(), the window’s MakeCurrent() call always fails. Why would MakeCurrent() work with vtk-8.2 but fail for vtk-9.0? I asked for help on this forum about a week ago, but haven’t received a response yet.

My code is here:  
[QVtkItem.h](https://github.com/dwcaress/MB-System/blob/feature-newgui/src/qt-guilib/QVtkItem.h)  
[QVtkItem.cpp](https://github.com/dwcaress/MB-System/blob/feature-newgui/src/qt-guilib/QVtkItem.cpp)  
[QVtkRenderer.h](https://github.com/dwcaress/MB-System/blob/feature-newgui/src/qt-guilib/QVtkRenderer.h)  
[QVtkRenderer.cpp](https://github.com/dwcaress/MB-System/blob/feature-newgui/src/qt-guilib/QVtkRenderer.cpp)

But perhaps I’m using the wrong approach - does VTK actually provide a working example or test case of what I am trying to do, that works with vtk-9?

Thanks!

---

<div class="post-metadata">

### Author: ![Tomasso](https://discourse.vtk.org/user_avatar/discourse.vtk.org/tomasso/32/5786_2.png) [@Tomasso](https://discourse.vtk.org/u/Tomasso)
#### Post date: [September 14, 2022, 9:58pm UTC](https://discourse.vtk.org/t/vtk-9-with-qml-examples/9347/2 "2022-09-14T21:58:44Z")

</div>

This problem is apparently due to a bug in vtk-9.0, as my application now works with vtk-9.2. Note that per advised in [vtkGenericOpenGLRenderWindow documentation](https://vtk.org/doc/nightly/html/classvtkGenericOpenGLRenderWindow.html), my code installs a callback that asserts the window as current when MakeCurrent() is called:

```auto
  // Invoke callback when renderWindow_ is made current
  renderWindow_->AddObserver(vtkCommand::WindowMakeCurrentEvent,
                             this, &QVtkRenderer::makeCurrentCallback);

```

And the callback does this:

```auto
/// Assert renderWindow_ as current in response to WindowMakeCurrent event
void QVtkRenderer::makeCurrentCallback(vtkObject *, unsigned long eid,
                                       void *callData) {

  std::cout << "makeCurrentCallback()!" << std::endl;

  // Assert render window as current
  renderWindow_->SetIsCurrent(true);
}

```
