# Rendering issue with vtkImageViewer2 and Qt (works with vtkImageViewer)

**URL:** https://discourse.vtk.org/t/rendering-issue-with-vtkimageviewer2-and-qt-works-with-vtkimageviewer/1529
**Category:** Support
**Created:** [August 8, 2019, 7:28pm UTC](https://discourse.vtk.org/t/rendering-issue-with-vtkimageviewer2-and-qt-works-with-vtkimageviewer/1529 "2019-08-08T19:28:51Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![NewProggie](https://discourse.vtk.org/user_avatar/discourse.vtk.org/newproggie/32/739_2.png) [@NewProggie](https://discourse.vtk.org/u/NewProggie)
#### Post date: [August 8, 2019, 7:28pm UTC](https://discourse.vtk.org/t/rendering-issue-with-vtkimageviewer2-and-qt-works-with-vtkimageviewer/1529/1 "2019-08-08T19:28:51Z")

</div>

Hello my fellow VTK users,

I want to embed an instance of `vtkImageViewer2` into my Qt5 application to visualize a series of DICOM images. I’m currently experiencing some rendering issues because the widget doesn’t display anything.

When I’m using `vtkImageViewer` instead of `vtkImageViewer2` it displays the first image of the series. However, I’d like to use `vtkImageViewer2` because it adds a lot of functionality that I need.

Following is a self-contained code snippet that demonstrates the problem:

```auto
int main() {

  QSurfaceFormat::setDefaultFormat(QVTKOpenGLNativeWidget::defaultFormat());
  QApplication app(argc, argv);
  QVTKOpenGLWidget widget;
  vtkNew<vtkGenericOpenGLRenderWindow> renderWindow;
  widget.SetRenderWindow(renderWindow);

  vtkNew<vtkDICOMImageReader> reader;
  reader->SetDirectoryName("/my/DICOM/images");
  reader->Update();

  // vtkNew<vtkImageViewer> imageViewer; // this works!!
  vtkNew<vtkImageViewer2> imageViewer; 
  imageViewer->SetRenderWindow(renderWindow);
  imageViewer->SetInputConnection(reader->GetOutputPort());
  imageViewer->SetupInteractor(renderWindow->GetInteractor());

  widget.show();
  return app.exec();
}

```

P.S: Cross-post to [https://stackoverflow.com/questions/57409267/rendering-issue-with-vtkimageviewer2-and-qt-works-with-vtkimageviewer](https://stackoverflow.com/questions/57409267/rendering-issue-with-vtkimageviewer2-and-qt-works-with-vtkimageviewer)
