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

Evan Kao tossin at gmail.com
Tue Apr 12 19:59:32 EDT 2016


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160412/07d8e025/attachment.html>


More information about the vtkusers mailing list