# QVKTWdiget and Interactors

**URL:** https://discourse.vtk.org/t/qvktwdiget-and-interactors/8161
**Category:** Support
**Created:** [March 29, 2022, 12:37am UTC](https://discourse.vtk.org/t/qvktwdiget-and-interactors/8161 "2022-03-29T00:37:04Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![BlueKnight7](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/838e76/32.png) [@BlueKnight7](https://discourse.vtk.org/u/BlueKnight7)
#### Post date: [March 29, 2022, 12:37am UTC](https://discourse.vtk.org/t/qvktwdiget-and-interactors/8161/1 "2022-03-29T00:37:04Z")

</div>

I’ve been working for hours trying to get the orientation marker from the OrientationMarkerWidget example to work with the QVTKWidget in the SimpleView example – with no success. I’ve looked at a number of the the other VTK examples for both interactors and Qt and I can’t find anything that seems to be of much help.

I found a comment on the web from something on [public.kitware.com](http://public.kitware.com) that says that the qvtkwidget is suppose to handle the interactor. So, at this point I’m totally confused.

Can someone explain how to set / get the interactor for the qvtkwidget and how to set it for the orientation marker? I gather from what I’ve seen so far that the order of operations for this is important w.r.t. initializing and starting the interactor.

---

<div class="post-metadata">

### Author: ![BlueKnight7](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/838e76/32.png) [@BlueKnight7](https://discourse.vtk.org/u/BlueKnight7)
#### Post date: [April 1, 2022, 1:03am UTC](https://discourse.vtk.org/t/qvktwdiget-and-interactors/8161/2 "2022-04-01T01:03:05Z")

</div>

Okay. So, a number of people viewing, but no response.

I’ve be beating my head against the wall on this over days. No web searches yield any working examples.

## Here is how I’ve modified the SimpleView code to add the orientation marker from the DisplayCoordinateAxes example.

// Actor in scene  
vtkNew actor;  
actor-\>SetMapper(mapper);

// VTK Renderer  
vtkNew ren;  
ren-\>SetBackground(0.8, 0.8, 0.8);

// Add Actor to renderer  
ren-\>AddActor(actor);

// VTK/Qt wedded  
vtkNew renderWindow;  
this-\>ui-\>qvtkWidget-\>setRenderWindow(renderWindow);  
this-\>ui-\>qvtkWidget-\>renderWindow()-\>AddRenderer(ren);

vtkRenderWindowInteractor \*iren = renderWindow-\>GetInteractor();

vtkNew axes;

vtkNew widget;  
double rgba[4]{0.0, 0.0, 0.0, 0.0};  
colors-\>GetColor(“Carrot”, rgba);  
widget-\>SetOutlineColor(rgba[0], rgba[1], rgba[2]);  
widget-\>SetOrientationMarker(axes);  
widget-\>SetViewport(0.0, 0.0, 0.4, 0.4);

widget-\>SetInteractor(iren);  
widget-\>SetEnabled(1);  
widget-\>InteractiveOn();

ren-\>ResetCamera();  
renderWindow-\>Render();

* * *

This program executes, but the axes actor is never displayed and there are no execution error messages.

Does anyone have any idea why this doesn’t work? In theory, this should be fairly straight forward.

---

<div class="post-metadata">

### Author: ![BlueKnight7](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/838e76/32.png) [@BlueKnight7](https://discourse.vtk.org/u/BlueKnight7)
#### Post date: [April 8, 2022, 2:04pm UTC](https://discourse.vtk.org/t/qvktwdiget-and-interactors/8161/3 "2022-04-08T14:04:34Z")

</div>

I’m going to answer my own query, just in case someone in the future encounters the same problem. For novice users just starting out on the vtk leaning curve, this may be helpful.

The issue is one of scope.

The examples on the [vtk.org](http://vtk.org) website are a nice introduction to features, but one must remember that the cxx code that is displayed is really just c code with one main function. No one writes anything but demonstration code that way. Well, at least no one who is a serious developer. 🙂

When I moved the _ **vtkNew\<vtkAxesActor\> axes** _ declarations out of the class function to the class header file – that is moved them from being local to being owned by the class – it all worked.
