[vtkusers] Is there an elegant way to switch event handling between VTK and Qt when using QVTKRenderWindowInteractor in Python?

Justin Weber onlyjus at gmail.com
Tue Apr 12 21:00:16 EDT 2016


Whatever widget currently has the focus will get the events. You can
manually set what widget has the focus by calling the setFocus() method of
that widget. You can check if a widget has a focus by calling the
hasFocus() method. You can look at the widget documentation for more event
methods:
http://doc.qt.io/qt-4.8/qwidget-members.html

So what are you actually trying to do?

Justin
On Apr 12, 2016 8:02 PM, "Evan Kao" <tossin at gmail.com> wrote:

> Hello vtk-users,
>
> I'm playing around with QVTKRenderWindowInteractor and had a question
> about handling events.  Specifically is it possible to pick who is handling
> the events between PyQt and VTK?
>
> For instance, say I have the following setup:
>
> class View(QMainWindow):
>
>   def __init__(self, ...):
>     ...
>     self.vtkWidget = QVTKRenderWindowInteractor(...)
>     ...
>
>   def keyPressEvent(self, e):
>     ...
>
>
> At the start of the application, any key press event will be handled by
> the keyPressEvent method.  But once I click on the vtkWidget, all events
> are handled by the vtkWidget's RenderWindowInteractor and there doesn't
> seem like a convenient way to switch control back to the main window.  At
> least for me, clicking on other parts of the application window does not
> return control to Qt.
>
> I have noticed that if I press a button, event handling is returned to
> keyPressEvent, but it seems a little cumbersome to have to set up a dummy
> button to switch between VTK and Qt.  Is there a smarter way?
>
> Also, if it matters, I'm using PyQt 4.11.4, VTK 5.10.0, Python 2.7.11 on a
> Windows 7 64-bit machine.
>
> Thanks,
> Evan Kao
>
> _______________________________________________
> 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
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160412/dca38c0c/attachment.html>


More information about the vtkusers mailing list