[vtkusers] Give keyboard focus to a QVTKWidget without "touching" it
Shakes
Shekhar.Chandra at sci.monash.edu.au
Wed Jan 16 17:58:16 EST 2008
Hi Jesus,
Qt has something called Strong Focus (click and keyboard focus) option.
All u need to do is to set the FocusPolicy to StrongFocus, also there is
a help page for keyboard focusing in Qt Documentation. Also if you have
multiple windows in workspace, then set active window in QWorkspace. If
u have multiple windows in general, then setFocus should work if called
from the correct spot.
Hope that helps.
Cheers
Shakes
Jesús Spínola wrote:
> 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!
> ------------------------------------------------------------------------
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
More information about the vtkusers
mailing list