[vtkusers] Give keyboard focus to a QVTKWidget without "touching" it
Shakes
Shekhar.Chandra at sci.monash.edu.au
Thu Jan 17 18:16:45 EST 2008
Hi Jesus,
In order to accept keyboard presses, the window needs to be active. The
only way I see how u can make it active other than clicking is strong
focus, as u can tab to the window. I guess I don't understand exactly
why u need to focus on the window automatically. Do you mean u have
multiple windows and the default window focused not the right one? More
detail on the window setup would help.
Cheers
Shakes
Jesús Spínola wrote:
>
>
> On Jan 16, 2008 11:58 PM, Shakes <Shekhar.Chandra at sci.monash.edu.au
> <mailto: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
> >
>
>
More information about the vtkusers
mailing list