# 2D vtk Renders in QT

**URL:** https://discourse.vtk.org/t/2d-vtk-renders-in-qt/1231
**Category:** Support
**Created:** [June 28, 2019, 5:26am UTC](https://discourse.vtk.org/t/2d-vtk-renders-in-qt/1231 "2019-06-28T05:26:49Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ChristopherWaters](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/c/d78d45/32.png) [@ChristopherWaters](https://discourse.vtk.org/u/ChristopherWaters)
#### Post date: [June 28, 2019, 5:26am UTC](https://discourse.vtk.org/t/2d-vtk-renders-in-qt/1231/1 "2019-06-28T05:26:49Z")

</div>

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:

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

```

Additional Code in main file:

```auto
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)

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [June 28, 2019, 5:34am UTC](https://discourse.vtk.org/t/2d-vtk-renders-in-qt/1231/2 "2019-06-28T05:34:37Z")

</div>

See example in CTK library - [Using QVTKOpenGLWidget with vtkContextItem-derived class](https://discourse.vtk.org/t/using-qvtkopenglwidget-with-vtkcontextitem-derived-class/1092/2)

---

<div class="post-metadata">

### Author: ![ChristopherWaters](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/c/d78d45/32.png) [@ChristopherWaters](https://discourse.vtk.org/u/ChristopherWaters)
#### Post date: [June 28, 2019, 5:45am UTC](https://discourse.vtk.org/t/2d-vtk-renders-in-qt/1231/3 "2019-06-28T05:45:20Z")

</div>

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

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