# OpenGL state errors with QVTKOpenGLWidget and vtk8.2

**URL:** https://discourse.vtk.org/t/opengl-state-errors-with-qvtkopenglwidget-and-vtk8-2/539
**Category:** Support
**Created:** [March 19, 2019, 9:52pm UTC](https://discourse.vtk.org/t/opengl-state-errors-with-qvtkopenglwidget-and-vtk8-2/539 "2019-03-19T21:52:21Z")
**Posts on this page:** 1
**Showing post:** 7

<div class="post-metadata">

### Author: ![geoffw](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/g/898d66/32.png) [@geoffw](https://discourse.vtk.org/u/geoffw)
#### Post date: [March 20, 2019, 3:46pm UTC](https://discourse.vtk.org/t/opengl-state-errors-with-qvtkopenglwidget-and-vtk8-2/539/7 "2019-03-20T15:46:31Z")

</div>

Mathieu,

Thanks, I found the answer there:

```
// Make sure that the widget context is valid before making OpenGL calls.
// This should only take up to 4 calls to processEvents(). If this test keeps
// timing out, consider that the widget initialization is broken.
while (!_qvtkWidget->isValid()) {
    app.processEvents();
}

```

The OpenGL initialization occurs as a result of a Qt event! DOH!

---

_[View the full topic](https://discourse.vtk.org/t/opengl-state-errors-with-qvtkopenglwidget-and-vtk8-2/539)._
