# How can I use a vtk interactor with an external event loop?

**URL:** https://discourse.vtk.org/t/how-can-i-use-a-vtk-interactor-with-an-external-event-loop/335
**Category:** Support
**Created:** [February 26, 2019, 8:33pm UTC](https://discourse.vtk.org/t/how-can-i-use-a-vtk-interactor-with-an-external-event-loop/335 "2019-02-26T20:33:16Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![langer](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/l/3e96dc/32.png) [@langer](https://discourse.vtk.org/u/langer)
#### Post date: [February 26, 2019, 8:33pm UTC](https://discourse.vtk.org/t/how-can-i-use-a-vtk-interactor-with-an-external-event-loop/335/1 "2019-02-26T20:33:16Z")

</div>

I have a program that has a GUI written in gtk+2 and uses vtk for 3D graphics. Currently we handle all mouse and keyboard events in gtk+2, and don’t use a vtkRenderWindowInteractor at all. We call vtk methods in response to mouse events in the gtk event loop. This is a bit cumbersome, and think life would be easier if we could use a vtkRenderWindowInteractor and vtkInteractorStyle instead. However, it would be very difficult to give up the gtk event loop. I’d rather hook into the vtk interactor from an idle callback or event handler in the gtk event loop. It looks like this is possible – the documentation for vtkRenderWindowInteractor::Start() says that it’s possible to use ones own event loop. How do I do that? I can’t find an example or instructions…

Thanks.

---

<div class="post-metadata">

### Author: ![Edoardo\_Pasca](https://discourse.vtk.org/user_avatar/discourse.vtk.org/edoardo_pasca/32/742_2.png) [@Edoardo\_Pasca](https://discourse.vtk.org/u/Edoardo_Pasca)
#### Post date: [August 9, 2019, 11:32am UTC](https://discourse.vtk.org/t/how-can-i-use-a-vtk-interactor-with-an-external-event-loop/335/2 "2019-08-09T11:32:48Z")

</div>

I think something similar is done in the QVTKWidget where the vtkInteractor’s render loop is not started and the interaction is forwarded from Qt to VTK.

[https://vtk.org/doc/nightly/html/classQVTKWidget.html#details](https://vtk.org/doc/nightly/html/classQVTKWidget.html#details)

Edo
