[vtkusers] VTK 6.2 and PyQt5?

clinton at elemtech.com clinton at elemtech.com
Fri Feb 5 12:46:09 EST 2016

----- On Feb 5, 2016, at 10:26 AM, David Gobbi <david.gobbi at gmail.com> wrote: 

> On Fri, Feb 5, 2016 at 9:15 AM, Elvis Stansvik < elvis.stansvik at orexplore.com >
> wrote:

>> Alright, so you've heard about it before? Should there ever be a need for
>> QGLWidget, or should it be reported as a bug?

>> My system:

>> Thinkpad T440s
>> Intel HD Graphics 4400
>> Qt 5.5.1 / PyQt5 5.4.2 / VTK 6.2.0

>> All installed from Kubuntu repos (with backports repositories enabled).

>> I have no reason not to use QGLWidget instead of QWidget, so it's not a big
>> problem. I was mostly curious if others have seen this problem.

> Yes, the depth buffer for the context seems to be missing. The person who
> submitted the QGLWidget patch had exactly the same issue:
> https://gitlab.kitware.com/vtk/vtk/merge_requests/1097

> That was for linux on a virtual machine, so I thought it was the fault of the
> virtual machine. But maybe it wasn't after all!

> I use linux as well, with NVidia graphics, for me it works without QGLWidget.

> - David

Perhaps the following explanation will clear some things up, and help people understand when and why the problems shows up. 

The C++ QVTKWidget class addresses this issue by controlling the X11 visual when creating the window. See QVTKWidget::x11_setup_window(). 
I don't think this issue is related to what OpenGL driver is used, but rather what X11 visual is the default or chosen by Qt. 

On Linux, you can run 
$ xdpyinfo | default 
to get the default visual for the X11 server. 
In my case, its 
default visual id: 0x21 

Then you run glxinfo to look up the capabilities of the default visual. 

In my case, visual 0x21 has the following capabilities. 
visual x bf lv rg d st colorbuffer sr ax dp st accumbuffer ms cav 
id dep cl sp sz l ci b ro r g b a F gb bf th cl r g b a ns b eat 
0x021 24 tc 0 24 0 r y . 8 8 8 0 . s 4 24 8 16 16 16 16 0 0 None 

My default visual 0x21 supports a depth buffer, but not alpha. To get alpha working with VTK, a different visual would be needed. 

When mixing OpenGL and X11, the application code is responsible for choosing the X11 visual that supports the capabilities one wants to get from OpenGL. 
By using QWidget, you get the default visual, unless overridden. By using QGLWidget, you possibly get another one, depending on the logic in QGLWidget based on QGLFormat. The default QGLFormat may or may not give you what you are expecting to get with VTK. Also, when using QGLWidget, you now have a window with 2 opengl contexts created for it. One by VTK, and another by Qt - and I find that confusing. 

In Qt 4.8, the QApplication constructor had support for specifying visuals, but that appears to have gone away with Qt 5. 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160205/a529af01/attachment.html>

More information about the vtkusers mailing list