[vtkusers] Detect which key was released on vtkCommand::KeyReleaseEvent
Alex Malyushytskyy
alexmalvtk at gmail.com
Tue Jul 30 21:15:31 EDT 2013
VTK way : look at the examp[le below:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/Interaction/KeypressEvents
QT way:
If you subclass QVTKWidget you can override
bool QVTKWidget::event(QEvent* e)
also you can installEventFilter for QVTKWidget instance without
subclassing.
Regards,
Alex
On Tue, Jul 30, 2013 at 8:48 AM, Girault, Alexis <girault at email.unc.edu>wrote:
> Hey all,
> *
> I would like to interact with a QVTKwidget when I release the ESC key.*
>
> 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 :
>
> *meshWidget->GetInteractor()->AddObserver(vtkCommand::KeyReleaseEvent,
> this, &ShapePopulationViewer::UnselectWidget);*
>
>
> I'd like to verify if the key that was released was ESC, just like this
> line for Ctrl :
>
> *if(selectedInteractor->GetControlKey()==1)*
>
>
> If it is easier it can be when I press ESC (*KeyPressedEvent)* instead,
> but I still need to identify the Key.*
>
> *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 :
>
> *void myclass::keyPressEvent(QKeyEvent *event){*
> * if((event->key() == Qt::Key_Escape)){*
> * [...]*
> *}}*
>
>
> Any idea? Thank you. Alexis
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130730/107fcb3e/attachment.htm>
More information about the vtkusers
mailing list