[vtkusers] [Qt-interest] QT and VTK interactor how to manage the signals

Giancarlo Amati ilferraresebono at hotmail.it
Tue Mar 2 11:29:47 EST 2010


Beautiful! 
Thanks for the help! :)

Giancarlo

> From: enrico.qt at email.it
> To: qt-interest at trolltech.com
> Subject: Re: [Qt-interest] [vtkusers] QT and VTK interactor how to manage the signals
> Date: Tue, 2 Mar 2010 17:14:45 +0100
> CC: ilferraresebono at hotmail.it; vtkusers at vtk.org
> 
> On Tuesday 02 March 2010 16:19:37 Giancarlo Amati wrote:
> > Hi Clinton,
> > thanks a lot for the answer. I just would like to make an example.
> > Let's say that if I have a QVTKWidget in my QT interface and I press W on
> > the keyword, that event is detected by QT (first) which forward it to the
> > QVTKWidget and then the interactor. is that right?
> > 
> > So I wonder, if I make QT managing the press of W first and then I would
> > like QVTKWidget doing whatever is programmed to do, would it be enough to
> > add the correspondent handler in my QT Class (whatever it is? )
> > 
> > Thanks
> > Giancarlo
> 
> 
> Hello Giancarlo, here is an example that may be useful to you:
> 
> 1. when initializing the widget, connect to the signal you want 
> 
> // connect Vtk Events to Qt Slots
> m_connections = vtkEventQtSlotConnect::New();
> 
> // get key pressed with high priority (1.0)
> m_connections->Connect(m_widget->GetRenderWindow()->GetInteractor(), 
> vtkCommand::KeyPressEvent, target, SLOT(slotKeyPressed(vtkObject*, unsigned 
> long, void*, void*, vtkCommand*)), 0, 1.0); // <-notice the 1.0
> 
> 2. in your slot:
> 
> void Target::slotKeyPressed(vtkObject *, unsigned long, void *, void *, 
> vtkCommand *command)
> {
>     if ( doSomething() ) {
>         // consume event so the interactor doesn't get it
>         command->AbortFlagOn();
>     }
> }
> 
> So you can handle the key press and you're the first to do so (1.0) and if you 
> want to stop the Interactor from getting the event, you can do it by calling 
> AbortFlagOn();
> 
> Does this solve your problems?
> 
> Ciao,
> Enrico Ros
 		 	   		  
_________________________________________________________________
Più spazio per le tue esigenze. Hotmail va oltre i 5GB
http://www.windowslive.it/hotmail/SpazioDisponibile.aspx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100302/946ebb89/attachment.htm>


More information about the vtkusers mailing list