2D vtk Renders in QT

I am unable to do 2D vtk renders in QT without having override errors:
“Generic Warning: In vtkContextDevice2D.cxx, line 31 Error: no override found for 'vtkContextDevice2D”.

While trying to solve this I have been reading about the vtkContextView and vtkGenericOpenGLRenderWindow classes.

vtkGenericOpenGLRenderWindow:

vtkGenericOpenGLRenderWindow provides a skeleton for implementing a render window using one’s own OpenGL context and drawable. To be effective, one must register an observer for WindowMakeCurrentEvent, WindowIsCurrentEvent and WindowFrameEvent.

vtkContextView:

This class is derived from vtkRenderViewBase and provides a view of a vtkContextScene, with a default interactor style, renderer etc. It is the simplest way to create a vtkRenderWindow and display a 2D scene inside of it.

I do not understand how the vtkContextView works with OpenGL and was wondering if someone could help explain their relation to one another, and how the context view works.

Also, is there any other way to do 2D vtk renders without the using the context view? I cannot find any exmaples of 2D vtk renders in QT, any advice on how to do 2D renders of vtk in QT will be greatly appreciated .

Current Attempt to render 2D vtk chart:

view->SetRenderWindow(this->qvtkWidgetRight->GetRenderWindow());
view->SetInteractor(this->qvtkWidgetRight->GetInteractor());

Additional Code in main file:

QSurfaceFormat::setDefaultFormat(QVTKOpenGLNativeWidget::defaultFormat());

Additional Info: Win64 on 64bit machine, vtk8.2.0, Qt5.13.0, compiled/built in MCVS2017(Release x64) with cmake3.15.0 (EVerything else works fine, even 3D vtk renderings)

See example in CTK library - Using QVTKOpenGLWidget with vtkContextItem-derived class

1 Like

Just got it working, CMake file didn’t have vtkRenderingContextOpenGL2.

THANK YOU SO MUCH I HAVE SPENT A WEEK TRYING TO FIX THIS

2 Likes