# Which Qt and VTK for QVTKOpenGLWidget?

**URL:** https://discourse.vtk.org/t/which-qt-and-vtk-for-qvtkopenglwidget/1588
**Category:** Support
**Created:** [August 16, 2019, 1:11am UTC](https://discourse.vtk.org/t/which-qt-and-vtk-for-qvtkopenglwidget/1588 "2019-08-16T01:11:32Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![Gib\_Bogle](https://discourse.vtk.org/user_avatar/discourse.vtk.org/gib_bogle/32/740_2.png) [@Gib\_Bogle](https://discourse.vtk.org/u/Gib_Bogle)
#### Post date: [August 16, 2019, 1:11am UTC](https://discourse.vtk.org/t/which-qt-and-vtk-for-qvtkopenglwidget/1588/1 "2019-08-16T01:11:32Z")

</div>

In an attempt to avoid the segfault I’m getting with QVTKWidget (Qt-4.8, VTK-5.10) I am planning to upgrade to a version of VTK that includes QVTKOpenGLWidget. In which VTK version did this widget first appear? Will I need a later version of Qt as well? If possible I’d like to avoid having to make many code changes.

Thanks  
Gib

---

<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: [August 16, 2019, 12:54pm UTC](https://discourse.vtk.org/t/which-qt-and-vtk-for-qvtkopenglwidget/1588/2 "2019-08-16T12:54:25Z")

</div>

The first version of VTK containing QVTKOpenGLWidget is VTK 8.0.0  
However, it has been reworked deeply recently, so I would suggest going for the next release this year, once it’s out.

---

<div class="post-metadata">

### Author: ![Gib\_Bogle](https://discourse.vtk.org/user_avatar/discourse.vtk.org/gib_bogle/32/740_2.png) [@Gib\_Bogle](https://discourse.vtk.org/u/Gib_Bogle)
#### Post date: [August 17, 2019, 1:48am UTC](https://discourse.vtk.org/t/which-qt-and-vtk-for-qvtkopenglwidget/1588/3 "2019-08-17T01:48:49Z")

</div>

Thanks Mathieu,  
To get up to speed, I have installed Qt5, and built VTK-8.2.0 with Qt GUI support. To start with I am leaving my code as is, i.e. still using QVTKWidget. After many adjustments (to account for the changes from old versions of Qt and VTK) I am almost building my program (in Qt Creator). Now I just get one linking error:

/usr/local/lib/vtk-8.2/libvtkGUISupportQt-8.2.a(QVTKWidget.cxx.o)👎 In function `QVTKWidget::SetRenderWindow(vtkRenderWindow*)': QVTKWidget.cxx:-1: error: undefined reference to`QX11Info::display()’

Does this convey anything to you? Does it mean QVTKWidget is not just deprecated, it is also invalid?

Thanks  
Gib

---

<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: [August 19, 2019, 8:53am UTC](https://discourse.vtk.org/t/which-qt-and-vtk-for-qvtkopenglwidget/1588/4 "2019-08-19T08:53:52Z")

</div>

It is not invalid. looks like you are missing a link to x11extras, could you add it to see if this fixes it ?

---

<div class="post-metadata">

### Author: ![Gib\_Bogle](https://discourse.vtk.org/user_avatar/discourse.vtk.org/gib_bogle/32/740_2.png) [@Gib\_Bogle](https://discourse.vtk.org/u/Gib_Bogle)
#### Post date: [August 25, 2019, 5:36am UTC](https://discourse.vtk.org/t/which-qt-and-vtk-for-qvtkopenglwidget/1588/5 "2019-08-25T05:36:57Z")

</div>

Hi Mathieu,  
Sorry to be so late in replying - got distracted onto other things.  
Yes, adding that library fixes the link error.  
Thanks  
Gib

---

<div class="post-metadata">

### Author: ![Gib\_Bogle](https://discourse.vtk.org/user_avatar/discourse.vtk.org/gib_bogle/32/740_2.png) [@Gib\_Bogle](https://discourse.vtk.org/u/Gib_Bogle)
#### Post date: [August 25, 2019, 6:07am UTC](https://discourse.vtk.org/t/which-qt-and-vtk-for-qvtkopenglwidget/1588/6 "2019-08-25T06:07:46Z")

</div>

The link is successful, but the program crashes while setting up a QVTKWidget. Here is the code, up to the call where the crash occurs:

MyVTK::MyVTK(QWidget \*page, QWidget \*key\_page)  
{  
zoomlevel = 0.7; [//0.25](https://0.25)  
double backgroundColor[] = {0.0,0.0,0.0};  
page\_VTK = page;  
Global::leftb = false;  
key\_canvas(key\_page);  
qvtkWidget = new QVTKWidget(page\_VTK,QFlag(0));  
QVBoxLayout \*layout = new QVBoxLayout;  
layout-\>addWidget(qvtkWidget);  
// Associate the layout with page\_VTK  
page\_VTK-\>setLayout(layout);  
// Create a renderer, and add it to qvtkWidget’s render window.  
// The renderer renders into the render window.  
ren = vtkRenderer::New();  
renWin = qvtkWidget-\>GetRenderWindow();

This works in VTK 6.3 with Qt 4.8. What am I doing wrong?  
This is on Ubuntu 16.04.

---

<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: [August 26, 2019, 6:29am UTC](https://discourse.vtk.org/t/which-qt-and-vtk-for-qvtkopenglwidget/1588/7 "2019-08-26T06:29:25Z")

</div>

Please refer to QVTKWidget examples.  
eg: `VTK/Examples/GUI/Qt/ImageViewer`

---

<div class="post-metadata">

### Author: ![Gib\_Bogle](https://discourse.vtk.org/user_avatar/discourse.vtk.org/gib_bogle/32/740_2.png) [@Gib\_Bogle](https://discourse.vtk.org/u/Gib_Bogle)
#### Post date: [August 26, 2019, 8:06am UTC](https://discourse.vtk.org/t/which-qt-and-vtk-for-qvtkopenglwidget/1588/8 "2019-08-26T08:06:48Z")

</div>

> [@mwestphal](#):
>
> `VTK/Examples/GUI/Qt/ImageViewer`

I see that this example uses QVTKOpenGLWidget. Does that imply that although QVTKWidget is still in VTK 8.2, it is not usable?

---

<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: [August 26, 2019, 8:11am UTC](https://discourse.vtk.org/t/which-qt-and-vtk-for-qvtkopenglwidget/1588/9 "2019-08-26T08:11:58Z")

</div>

Sorry, about that. I forgot the example got updated.

`VTK/Examples/GUI/Qt/Events` still uses QVTKWidget.

---

<div class="post-metadata">

### Author: ![Gib\_Bogle](https://discourse.vtk.org/user_avatar/discourse.vtk.org/gib_bogle/32/740_2.png) [@Gib\_Bogle](https://discourse.vtk.org/u/Gib_Bogle)
#### Post date: [August 26, 2019, 9:41am UTC](https://discourse.vtk.org/t/which-qt-and-vtk-for-qvtkopenglwidget/1588/10 "2019-08-26T09:41:49Z")

</div>

That example uses setRenderWindow, which is supposed to be a member function of QVTKWidget, e.g. see [https://vtk.org/doc/nightly/html/classQVTKWidget.html](https://vtk.org/doc/nightly/html/classQVTKWidget.html). But I get the compile error:  
class ‘QVTKWidget’ has no member named ‘setRenderWindow’  
Presumably there have been some changes to QVTKWidget by version 8.2. This raises the question: is QVTKWidget usable with VTK 8.2? setRenderWindow no longer exists, and getRenderWindow doesn’t give a compile error but causes my program to crash.

---

<div class="post-metadata">

### Author: ![Gib\_Bogle](https://discourse.vtk.org/user_avatar/discourse.vtk.org/gib_bogle/32/740_2.png) [@Gib\_Bogle](https://discourse.vtk.org/u/Gib_Bogle)
#### Post date: [August 26, 2019, 10:15pm UTC](https://discourse.vtk.org/t/which-qt-and-vtk-for-qvtkopenglwidget/1588/11 "2019-08-26T22:15:42Z")

</div>

Hi Mathieu,  
The compile error is with my own program. I haven’t managed to get to the build stage yet with the Events example, because when I run cmake I get this error:

CMake Error at CMakeLists.txt:46 (add\_executable):  
Target “qtevents” links to target “Qt5::X11Extras” but the target was not found. Perhaps a find\_package() call is missing for an IMPORTED target, or an ALIAS target is missing?

Based on this info from Marcus Hanwell: [https://blog.kitware.com/cmake-finding-qt5-the-right-way/](https://blog.kitware.com/cmake-finding-qt5-the-right-way/)  
I tried adding this:

set(Qt5\_DIR ~/Qt5.13.0/5.13.0/gcc\_64/lib/cmake/Qt5 )  
find\_package(Qt5 COMPONENTS Core Widgets REQUIRED)

since that directory contains Qt5Config.cmake, but the same error occurs. Do you know what I need to do to ensure that cmake finds X11Extras? The library libQt5X11Extras.so is present with all the other Qt5 libraries.

(I get the same cmake error with the SimpleView example. With the ImageViewer example I get that the vtkTestingCore module is not available - I guess I didn’t build it.)

Thanks.

Edit: If I ignore the cmake error and run make anyway, I get many warnings about QVTKWidget being deprecated, then this link error:  
[100%] Linking CXX executable qtevents  
/usr/bin/ld: cannot find -lQt5::X11Extras  
collect2: error: ld returned 1 exit status

Presumably there is a way to tell cmake where to find libQt5X11Extras.so, but it seems to be looking for a different name - libQt5::X11Extras.so. I don’t know how to treat that ‘Qt5::’.

Edit!!!  
I discovered that the build was not using the Qt installation that I intended, which led to the discovery that I hadn’t built VTK-8.2 with Qt-5.13.0 (an earlier Qt installation was being used). Rebuilding VTK-8.2 with the right Qt fixed the example build problem (after I added X11Extras to the find-package list) - the Events example now works. I still have to sort out my own program

---

<div class="post-metadata">

### Author: ![Gib\_Bogle](https://discourse.vtk.org/user_avatar/discourse.vtk.org/gib_bogle/32/740_2.png) [@Gib\_Bogle](https://discourse.vtk.org/u/Gib_Bogle)
#### Post date: [August 27, 2019, 9:27pm UTC](https://discourse.vtk.org/t/which-qt-and-vtk-for-qvtkopenglwidget/1588/12 "2019-08-27T21:27:38Z")

</div>

I’ve given up on getting QVTKWidget to work in my program on Linux. I’ve tried with both Qt4-VTK5 and Qt5-VTK8, getRenderWindow() causes the program to crash and I can’t see why. I’m going to explore using Qt’s own 3D capabilities.

---

<div class="post-metadata">

### Author: ![embeddedmz](https://discourse.vtk.org/user_avatar/discourse.vtk.org/embeddedmz/32/12_2.png) [@embeddedmz](https://discourse.vtk.org/u/embeddedmz)
#### Post date: [April 16, 2020, 8:45pm UTC](https://discourse.vtk.org/t/which-qt-and-vtk-for-qvtkopenglwidget/1588/13 "2020-04-16T20:45:55Z")

</div>

> The first version of VTK containing QVTKOpenGLWidget is VTK 8.0.0  
> However, it has been reworked deeply recently, so I would suggest going for the next release this year, once it’s out.

Hi @mwestphal

So, ParaView 5.4.1 (the one that can be installed with a package manager in Centos 7 or Ubuntu) is not using VTK 7.1.1 (I thought it was using that version of VTK) ?

---

<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: [April 17, 2020, 7:32am UTC](https://discourse.vtk.org/t/which-qt-and-vtk-for-qvtkopenglwidget/1588/14 "2020-04-17T07:32:07Z")

</div>

@cory.quammen already answered you there, but for completeness, ParaView is not using a release of VTK, but a specific hash, which is a9b132548dc19b8e20898b424b31cafacbf39246 for ParaView 5.4.1.

> [@Glitches when passing from QVTKWidget to QVTKOpenGLWidget](https://discourse.vtk.org/t/glitches-when-passing-from-qvtkwidget-to-qvtkopenglwidget/3068/5):
>
> ParaView doesn’t track a VTK release, but a commit on the master branch at some point. 5.4.1 uses VTK commit a9b132548dc19b8e20898b424b31cafacbf39246.

---

<div class="post-metadata">

### Author: ![j-fu](https://discourse.vtk.org/user_avatar/discourse.vtk.org/j-fu/32/3977_2.png) [@j-fu](https://discourse.vtk.org/u/j-fu)
#### Post date: [April 17, 2020, 4:41pm UTC](https://discourse.vtk.org/t/which-qt-and-vtk-for-qvtkopenglwidget/1588/15 "2020-04-17T16:41:49Z")

</div>

Hi, FYI, I just was able to get QVTKOpenGLNativeWidget running together with vtkGenericOpenGLRenderWindow and QVTKInteractor on linux with 9.0.0.rc2  
and Qt 5.14.1 (from openSUSE tumbleweed system package).

One weird thing is that I had to set  
`vtkGenericOpenGLRenderWindow::SetGlobalMaximumNumberOfMultiSamples(0)`, sometimes  
resulting in strange antialiasing. Without that, rendering was basically impossible.
