# Is there any way to use vtkImageViewer2 in QT project?

**URL:** https://discourse.vtk.org/t/is-there-any-way-to-use-vtkimageviewer2-in-qt-project/6266
**Category:** Support
**Created:** [July 29, 2021, 9:27am UTC](https://discourse.vtk.org/t/is-there-any-way-to-use-vtkimageviewer2-in-qt-project/6266 "2021-07-29T09:27:11Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![jjjkk](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jjjkk/32/3720_2.png) [@jjjkk](https://discourse.vtk.org/u/jjjkk)
#### Post date: [July 29, 2021, 9:27am UTC](https://discourse.vtk.org/t/is-there-any-way-to-use-vtkimageviewer2-in-qt-project/6266/1 "2021-07-29T09:27:11Z")

</div>

I read the example about how to use vtk in qt. But it seems that I can just add a renderwinodws to QVTKWidget.  
But vtkImageViewer2 is not Inherhit from renderwinodw. I really want to use the function like SetSlice in vtkImageViewer2.  
So, is there any way to use vtkImageViewer2 in QT project? Or is there an example about display a sequence of images using renderwinodws.

Thanks.

---

<div class="post-metadata">

### Author: ![Andrew](https://discourse.vtk.org/user_avatar/discourse.vtk.org/andrew/32/3861_2.png) [@Andrew](https://discourse.vtk.org/u/Andrew)
#### Post date: [July 30, 2021, 4:47pm UTC](https://discourse.vtk.org/t/is-there-any-way-to-use-vtkimageviewer2-in-qt-project/6266/2 "2021-07-30T16:47:47Z")

</div>

Absolutely!

It’s been awhile so might be a bit outdated answer. But looking at some old code I have a QVTKOpenGLWidget named qvtk and I do the following (something similar should be done for the other Qt VTK widgets):

```auto
imageViewer = vtkSmartPointer<vtkImageViewer2>::New();
imageViewer->SetRenderWindow(qvtk->GetRenderWindow());
imageViewer->SetSliceOrientation(sliceOrientation);
qvtk->GetInteractor()->SetInteractorStyle(vtkSmartPointer<InteractorStyleImage>::New());

// ... Set vtkImageViewer2 input...

```

The important bits here are setting the vtkImageViewer2 render window to the one supplied by QVTK. And then set the correct interactor style.
