# Vtk 9.3.1 OpenGL rendering issue with Qt 6.5.6 | VS 2019

**URL:** <https://discourse.vtk.org/t/vtk-9-3-1-opengl-rendering-issue-with-qt-6-5-6-vs-2019/14626>\
**Category:** Development\
**Tags:** code\
**Created:** [September 26, 2024, 7:10pm UTC](https://discourse.vtk.org/t/vtk-9-3-1-opengl-rendering-issue-with-qt-6-5-6-vs-2019/14626 "2024-09-26T19:10:12Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![ataban](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/c5a1d2/32.png) [@ataban](https://discourse.vtk.org/u/ataban)\
**Post date:** [September 26, 2024, 7:10pm UTC](https://discourse.vtk.org/t/vtk-9-3-1-opengl-rendering-issue-with-qt-6-5-6-vs-2019/14626/1 "2024-09-26T19:10:12Z")

</div>

I am presently porting my application from qt5 to qt 6 which uses vtk 9.3.1.

Facing issue during loading of dicom images into qt window. White screen appears with blank display of image but having no issues in vs 2019.

I have 4 points to discuss:

1. During investigation found out that vtk have GUISupport module which internally have qt module (that have qt6/qt5 support )but does not get configured by default even though cmakelist.txt in vtk include GUISupport folder.
2. While adding GUISupport/Qt folder explicitly through top level cmakelist.txt getting error while cmake configure step - “vtk\_module\_find\_package”- tag not recognized. Why this tags are present if not supported in cmake?
3. After few round of research found that VTK\_MODULE\_ENABLE\_VTK\_GUISupportQt and VTK\_MODULE\_ENABLE\_VTK\_RenderingQt variables needs to be set in cmake configure. But just setting these variables would be enough to instruct vtk build that application needs qt6 support?
4. What is the right way to add qt6 paths during vtk configure and later on in vtk compilation?

---

<div class="post-metadata">

**Author:** ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)\
**Post date:** [September 27, 2024, 12:19pm UTC](https://discourse.vtk.org/t/vtk-9-3-1-opengl-rendering-issue-with-qt-6-5-6-vs-2019/14626/2 "2024-09-27T12:19:55Z")

</div>

> [@ataban](#):
>
> During investigation found out that vtk have GUISupport module which internally have qt module (that have qt6/qt5 support )but does not get configured by default even though cmakelist.txt in vtk include GUISupport folder.

Yes you have to enable it in CMake

> After few round of research found that VTK\_MODULE\_ENABLE\_VTK\_GUISupportQt and VTK\_MODULE\_ENABLE\_VTK\_RenderingQt variables needs to be set in cmake configure. But just setting these variables would be enough to instruct vtk build that application needs qt6 support?

Yes

> What is the right way to add qt6 paths during vtk configure and later on in vtk compilation?

Qt6\_DIR

---

<div class="post-metadata">

**Author:** ![ataban](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/c5a1d2/32.png) [@ataban](https://discourse.vtk.org/u/ataban)\
**Post date:** [September 28, 2024, 9:22am UTC](https://discourse.vtk.org/t/vtk-9-3-1-opengl-rendering-issue-with-qt-6-5-6-vs-2019/14626/3 "2024-09-28T09:22:55Z")

</div>

> [@mwestphal](#):
>
> ou have to enable it in CMake

Thanks for the reply.  
I can include Qt::GUISupportQt module in vtk build . but still unable to render images which uses vtk libraries.

I am using QGraphicsWidget as container widget of the image which uses QVTKOpenGLNativeWidget iternally and vtkGenericOpenGLRenderWindow as the render window which uses QVTKRenderWindowAdapter which render the image from the image data.

Any changes needs to be done for qt 6 ? The same apis were being used in qt5 .

Also why do we need guisupportQT module for qt 6? any special api from that we need to use?

---

<div class="post-metadata">

**Author:** ![ataban](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/c5a1d2/32.png) [@ataban](https://discourse.vtk.org/u/ataban)\
**Post date:** [September 30, 2024, 2:55am UTC](https://discourse.vtk.org/t/vtk-9-3-1-opengl-rendering-issue-with-qt-6-5-6-vs-2019/14626/4 "2024-09-30T02:55:44Z")

</div>

Also when trying with vtk 9.3.1 / examples folder , getting below errors.

1. vtkAlgorithm.cxx:940 ERR| vtkDataReader (000001DC7667C730): FillOutputPortInformation is not implemented.
2. vtkDemandDrivenPipeline:642 ERR| vtkCompositeDataPipeline (000001DC7661DE60): Algorithm vtkDataReader (000001DC7667C730) did not create output for port 0 when asked by REQUEST\_DATA\_OBJECT and does not specify any DATA\_TYPE\_NAME.

This makes look like something needs to be modified during the implementation.

---

<div class="post-metadata">

**Author:** ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)\
**Post date:** [September 30, 2024, 7:15am UTC](https://discourse.vtk.org/t/vtk-9-3-1-opengl-rendering-issue-with-qt-6-5-6-vs-2019/14626/5 "2024-09-30T07:15:09Z")

</div>

> [@ataban](#):
>
> Also when trying with vtk 9.3.1 / examples folder , getting below errors.

which example is not working specifically ?

---

<div class="post-metadata">

**Author:** ![ataban](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/c5a1d2/32.png) [@ataban](https://discourse.vtk.org/u/ataban)\
**Post date:** [October 1, 2024, 3:37am UTC](https://discourse.vtk.org/t/vtk-9-3-1-opengl-rendering-issue-with-qt-6-5-6-vs-2019/14626/6 "2024-10-01T03:37:20Z")

</div>

Examples\GUI\Qt\ImageViewer . - not working  
Examples\Medical\Cxx - not working.

These are not working using qt 6.5.6.

But i found one example -  
[python - Using vtkVolume16Reader without FilePrefix - Stack Overflow](https://stackoverflow.com/questions/52717604/using-vtkvolume16reader-without-fileprefix#:~:text=All%20examples%20I%20have%20found%20in%20python%20uses%20class%20vtkVolume16Reader)

which uses **vtkDICOMImageReader** ad this reader is producing the image. So as of now this is the only reader which is working in qt6.

---

<div class="post-metadata">

**Author:** ![sankhesh](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sankhesh/32/73_2.png) [@sankhesh](https://discourse.vtk.org/u/sankhesh)\
**Post date:** [October 1, 2024, 3:47pm UTC](https://discourse.vtk.org/t/vtk-9-3-1-opengl-rendering-issue-with-qt-6-5-6-vs-2019/14626/7 "2024-10-01T15:47:33Z")

</div>

Thanks for providing the examples that are not working. It is likely a configuration issue. I’ll take a quick look.

---

<div class="post-metadata">

**Author:** ![sankhesh](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sankhesh/32/73_2.png) [@sankhesh](https://discourse.vtk.org/u/sankhesh)\
**Post date:** [October 1, 2024, 5:05pm UTC](https://discourse.vtk.org/t/vtk-9-3-1-opengl-rendering-issue-with-qt-6-5-6-vs-2019/14626/8 "2024-10-01T17:05:40Z")

</div>

@ataban I just tested it and the examples seem to work fine irrespective of the Qt version (5 or 6).  
Could you please share code samples that reproduce the error you’re seeing?

---

<div class="post-metadata">

**Author:** ![ataban](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/c5a1d2/32.png) [@ataban](https://discourse.vtk.org/u/ataban)\
**Post date:** [October 3, 2024, 5:33am UTC](https://discourse.vtk.org/t/vtk-9-3-1-opengl-rendering-issue-with-qt-6-5-6-vs-2019/14626/9 "2024-10-03T05:33:57Z")

</div>

> [@sankhesh](#):
>
> onfiguration issue

Thanks for your reply.

Sharing source code , output and error code.

In other example found in stackOverflow -

[python - Using vtkVolume16Reader without FilePrefix - Stack Overflow](https://stackoverflow.com/questions/52717604/using-vtkvolume16reader-without-fileprefix#:~:text=All%20examples%20I%20have%20found%20in%20python%20uses%20class%20vtkVolume16Reader)

It loads the image mentioned in below example but in this case it is loading blank.

# source

// Create the renderer, the render window, and the interactor. The renderer  
// draws into the render window, the interactor enables mouse- and  
// keyboard-based interaction with the data within the render window.  
//  
vtkSmartPointer aRenderer = vtkSmartPointer::New();  
vtkSmartPointer renWin = vtkSmartPointer::New();  
renWin-\>AddRenderer(aRenderer);

```
vtkSmartPointer<vtkRenderWindowInteractor> iren =
    vtkSmartPointer<vtkRenderWindowInteractor>::New();
iren->SetRenderWindow(renWin);

// The following reader is used to read a series of 2D slices (images)
// that compose the volume. The slice dimensions are set, and the
// pixel spacing. The data Endianness must also be specified. The reader
// uses the FilePrefix in combination with the slice number to construct
// filenames using the format FilePrefix.%d. (In this case the FilePrefix
// is the root name of the file: quarter.)
vtkSmartPointer<vtkVolume16Reader> v16 = vtkSmartPointer<vtkVolume16Reader>::New();
v16->SetDataDimensions(64, 64);
v16->SetImageRange(1, 93);
v16->SetDataByteOrderToLittleEndian();
std::string dir = "C:/ci/projects/mediseen-data/osirix/brebix/Uncompressed/1.2.840.113704.1.111.2864.1161868417.2891.dcm";
v16->SetFilePrefix(dir.c_str());
v16->SetDataSpacing(3.2, 3.2, 1.5);

// An isosurface, or contour value of 500 is known to correspond to the
// skin of the patient. Once generated, a vtkPolyDataNormals filter is
// is used to create normals for smooth surface shading during rendering.
vtkSmartPointer<vtkContourFilter> skinExtractor = vtkSmartPointer<vtkContourFilter>::New();
skinExtractor->SetInputConnection(v16->GetOutputPort());
skinExtractor->SetValue(0, 500);

vtkSmartPointer<vtkPolyDataNormals> skinNormals = vtkSmartPointer<vtkPolyDataNormals>::New();
skinNormals->SetInputConnection(skinExtractor->GetOutputPort());
skinNormals->SetFeatureAngle(60.0);

vtkSmartPointer<vtkPolyDataMapper> skinMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
skinMapper->SetInputConnection(skinNormals->GetOutputPort());
skinMapper->ScalarVisibilityOff();

vtkSmartPointer<vtkActor> skin = vtkSmartPointer<vtkActor>::New();
skin->SetMapper(skinMapper);

// An outline provides context around the data.
//
vtkSmartPointer<vtkOutlineFilter> outlineData = vtkSmartPointer<vtkOutlineFilter>::New();
outlineData->SetInputConnection(v16->GetOutputPort());

vtkSmartPointer<vtkPolyDataMapper> mapOutline = vtkSmartPointer<vtkPolyDataMapper>::New();
mapOutline->SetInputConnection(outlineData->GetOutputPort());

vtkSmartPointer<vtkActor> outline = vtkSmartPointer<vtkActor>::New();
outline->SetMapper(mapOutline);
outline->GetProperty()->SetColor(0, 0, 0);

// It is convenient to create an initial view of the data. The FocalPoint
// and Position form a vector direction. Later on (ResetCamera() method)
// this vector is used to position the camera to look at the data in
// this direction.
vtkSmartPointer<vtkCamera> aCamera = vtkSmartPointer<vtkCamera>::New();
aCamera->SetViewUp(0, 0, -1);
aCamera->SetPosition(0, 1, 0);
aCamera->SetFocalPoint(0, 0, 0);
aCamera->ComputeViewPlaneNormal();
aCamera->Azimuth(30.0);
aCamera->Elevation(30.0);

// Actors are added to the renderer. An initial camera view is created.
// The Dolly() method moves the camera towards the FocalPoint,
// thereby enlarging the image.
aRenderer->AddActor(outline);
aRenderer->AddActor(skin);
aRenderer->SetActiveCamera(aCamera);
aRenderer->ResetCamera();
aCamera->Dolly(1.5);

// Set a background color for the renderer and set the size of the
// render window (expressed in pixels).
aRenderer->SetBackground(.2, .3, .4);
renWin->SetSize(640, 480);

// Note that when camera movement occurs (as it does in the Dolly()
// method), the clipping planes often need adjusting. Clipping planes
// consist of two planes: near and far along the view direction. The
// near plane clips out objects in front of the plane; the far plane
// clips out objects behind the plane. This way only what is drawn
// between the planes is actually rendered.
aRenderer->ResetCameraClippingRange();

// For testing, check if "-V" is used to provide a regression test image
/*if (argc >= 4 && strcmp(argv[2], "-V") == 0)
{
    renWin->Render();
    int retVal = vtkRegressionTestImage(renWin);

    if (retVal == vtkTesting::FAILED)
    {
        return EXIT_FAILURE;
    }
    else if (retVal != vtkTesting::DO_INTERACTOR)
    {
        return EXIT_SUCCESS;
    }
}*/

// Initialize the event loop and then start it.
iren->Initialize();
iren->Start();

```

# output

 ![vtk_image_example](https://discourse.vtk.org/uploads/default/original/2X/7/70fa61af473a6da7e635132b49d99341d17bee62.png)

# error screen

![error_screen_example](https://discourse.vtk.org/uploads/default/original/2X/9/9122ac1138013f6b6422ed03760b8b53ba862494.png)

---

<div class="post-metadata">

**Author:** ![ataban](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/c5a1d2/32.png) [@ataban](https://discourse.vtk.org/u/ataban)\
**Post date:** [October 3, 2024, 7:09am UTC](https://discourse.vtk.org/t/vtk-9-3-1-opengl-rendering-issue-with-qt-6-5-6-vs-2019/14626/10 "2024-10-03T07:09:25Z")

</div>

Also do you have any idea about the error :

```auto
QVTKInteractor.cxx:131 ERR| QVTKInteractor (0000023E6C587790): QVTKInteractor cannot control the event loop.

```

This is appearing when i am trying to load dicom image in qt6/qt5 without using any qtWidget . Using VTKIMAGEVIEWER, QVTKNativeOpenGLWidget, QVTKOpenGLRenderer, and interactor.

---

<div class="post-metadata">

**Author:** ![sankhesh](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sankhesh/32/73_2.png) [@sankhesh](https://discourse.vtk.org/u/sankhesh)\
**Post date:** [October 3, 2024, 12:06pm UTC](https://discourse.vtk.org/t/vtk-9-3-1-opengl-rendering-issue-with-qt-6-5-6-vs-2019/14626/11 "2024-10-03T12:06:09Z")

</div>

@ataban For loading DICOM data, please use the `vtkDICOMImageReader`. See the [ReadDICOM](https://examples.vtk.org/site/Cxx/IO/ReadDICOM/) example for reference.

> [@ataban](#):
>
> This is appearing when i am trying to load dicom image in qt6/qt5 without using any qtWidget . Using VTKIMAGEVIEWER, QVTKNativeOpenGLWidget, QVTKOpenGLRenderer, and interactor.

Those classes need a Qt application as they’re written with Qt widgets. Without a Qt application running, the interaction associated with those classes fails to create an event loop and hence the error.

---

<div class="post-metadata">

**Author:** ![ataban](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/c5a1d2/32.png) [@ataban](https://discourse.vtk.org/u/ataban)\
**Post date:** [October 8, 2024, 3:46am UTC](https://discourse.vtk.org/t/vtk-9-3-1-opengl-rendering-issue-with-qt-6-5-6-vs-2019/14626/12 "2024-10-08T03:46:04Z")

</div>

Thanks, i found soln for my problem.
