[vtkusers] Give keyboard focus to a QVTKWidget without "touching" it

Jesús Spí­nola jspinola at gmail.com
Wed Jan 16 07:40:08 EST 2008


Hi,

I have an application with a main "2D View" based upon a QVTKWidget and I
would like to handle keyboard events to control the interaction.
My problem is that I must click over this QVTKWidget to be aware of the
keyboard events, because until you click, you don't have keyboard focus.
To avoid this "first-click-to-get-keyboard-focus", I tried to call
QVTKWidget->setFocus() (inherited from QWidget), which seems to be the
trivial solution, but It does nothing and I have to click the QVTKWidget
still to get the focus. I also tried invoking some vtk events, like
*ButtonPressEvent, but with no succeess.

Maybe I'm missing something or I'm trying to do something impossible, I
don't know, but it would be nice if someone can give me some hint to find
out what I'm doing wrong.

So, how can I get the focus automatically?

Thanks in advance!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080116/8a54f104/attachment.htm>


More information about the vtkusers mailing list