<div dir="ltr"><div><div><div>VTK way : look at the examp[le below:<br><a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/Interaction/KeypressEvents">http://www.vtk.org/Wiki/VTK/Examples/Cxx/Interaction/KeypressEvents</a><br>
<br><br>QT way:<br>If you subclass QVTKWidget you can override <br>bool QVTKWidget::event(QEvent* e)<br><br></div>also you can  installEventFilter for QVTKWidget instance without subclassing.<br><br></div>Regards,<br></div>
   Alex<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jul 30, 2013 at 8:48 AM, Girault, Alexis <span dir="ltr">&lt;<a href="mailto:girault@email.unc.edu" target="_blank">girault@email.unc.edu</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div>
<div style="direction:ltr;font-size:10pt;font-family:Tahoma">Hey all,<br>
<b><br>
I would like to interact with a QVTKwidget when I release the ESC key.</b><br>
<br>
I am able to add an observer on the Interactor of my QVTKwidget this way, that calls the function UnselectWidget() anytime I release a key if i was interacting with my QVTKwidget :<br>
<blockquote><i>meshWidget-&gt;GetInteractor()-&gt;AddObserver(vtkCommand::KeyReleaseEvent, this, &amp;ShapePopulationViewer::UnselectWidget);</i><br>
</blockquote>
<br>
I&#39;d like to verify if the key that was released was ESC, just like this line for Ctrl  :<br>
<blockquote><i>if(selectedInteractor-&gt;GetControlKey()==1)</i><br>
</blockquote>
<br>
If it is easier it can be when I press ESC (<i>KeyPressedEvent)</i> instead, but I still need to identify the Key.<i><br>
<br>
</i>I tried to use the QT function this way instead, but the function is only called when I am in the main window, and is not recognized when I am interacting with the QVTKwidget :<br>
<blockquote><i>void myclass::keyPressEvent(QKeyEvent *event){</i><br>
<i>    if((event-&gt;key() == Qt::Key_Escape)){</i><br>
<i>    [...]</i><br>
<i>}}</i><br>
</blockquote>
<br>
Any idea? Thank you. Alexis<br>
</div>
</div>

<br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br></div>