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

Jesús Spí­nola jspinola at gmail.com
Thu Jan 17 11:08:30 EST 2008


On Jan 16, 2008 11:58 PM, Shakes <Shekhar.Chandra at sci.monash.edu.au> wrote:

> 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.


I've already tried doing that. I've set FocusPolicy to StrongFocus but with
no success. I don't know what could be wrong

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
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080117/663085d4/attachment.htm>


More information about the vtkusers mailing list