<div style="font-family:ËÎÌå;font-size:medium;color:#0000FF;;"><DIV>hi,</DIV>
<DIV>&nbsp;I wanna use QScrollBar and QSpinBox to respond with the slice image(axial,coronal,sagittal) of a volume in QVTKWidget.</DIV>
<DIV>So i wrote a ScrollBarCallback class .The code is as follows:</DIV>
<DIV>class ScrollBarCallback: public vtkCommand<BR>{<BR>public:<BR>&nbsp;static ScrollBarCallback *New()<BR>&nbsp;{return new ScrollBarCallback();};</DIV>
<DIV>&nbsp; ScrollBarCallback()<BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp; this-&gt;ScrollBar=0;<BR>&nbsp;&nbsp;&nbsp; this-&gt;Qinteractor=0;<BR>&nbsp;&nbsp;&nbsp; this-&gt;ImagePlaneWidget=0;</DIV>
<DIV>&nbsp; };<BR>&nbsp; void SetScrollBar(QScrollBar *scollbar)<BR>&nbsp; {<BR>&nbsp;&nbsp; this-&gt;ScrollBar=scollbar;</DIV>
<DIV>&nbsp; };<BR>&nbsp; QScrollBar *GetScrollBar()<BR>&nbsp; {<BR>&nbsp; return this-&gt;ScrollBar;<BR>&nbsp; };<BR>&nbsp; void SetInteractor(QVTKInteractor *interactor)<BR>&nbsp; {<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp; this-&gt;Qinteractor = interactor;<BR>&nbsp; };</DIV>
<DIV>&nbsp;QVTKInteractor *GetInteractor() <BR>&nbsp;{<BR>&nbsp; &nbsp;return this-&gt;Qinteractor;<BR>&nbsp;};</DIV>
<DIV>&nbsp;void SetImagePlaneWidget(vtkImagePlaneWidget *imageplane)<BR>&nbsp;{<BR>&nbsp; this-&gt;ImagePlaneWidget=imageplane;<BR>&nbsp;};<BR>vtkImagePlaneWidget *GetImagePlaneWidget()<BR>{<BR>&nbsp; return this-&gt;ImagePlaneWidget;<BR>};</DIV>
<DIV>virtual void Execute(vtkObject *, unsigned long event , void* )</DIV>
<DIV>{<BR>&nbsp; QScrollBar * slider=this-&gt;GetScrollBar();<BR>&nbsp; QVTKInteractor *interactor=this-&gt;GetInteractor();<BR>&nbsp; vtkImagePlaneWidget *imageplane= this-&gt;GetImagePlaneWidget();<BR>&nbsp;&nbsp; imageplane-&gt;SetInteractor(interactor);<BR>&nbsp; imageplane-&gt;SetSliceIndex(slider-&gt;value());</DIV>
<DIV>&nbsp; interactor-&gt;Start();</DIV>
<DIV>};</DIV>
<DIV>private:</DIV>
<DIV>&nbsp;QScrollBar *ScrollBar;<BR>&nbsp;QVTKInteractor *Qinteractor;<BR>&nbsp;vtkImagePlaneWidget *ImagePlaneWidget;</DIV>
<DIV>&nbsp;</DIV>
<DIV>};</DIV>
<DIV>&nbsp;</DIV>
<DIV>GUI4::GUI4()<BR>{<BR>&nbsp; this-&gt;setupUi(this);</DIV>
<DIV>&nbsp;  renwin = vtkRenderWindow::New();<BR>&nbsp; renwin-&gt;StereoCapableWindowOn();</DIV>
<DIV>&nbsp; qVTK2-&gt;SetUseTDx(true);<BR>&nbsp; qVTK2-&gt;SetRenderWindow(renwin);<BR>&nbsp; renwin-&gt;Delete();</DIV>
<DIV>&nbsp; QVTKInteractor *iren2=qVTK2-&gt;GetInteractor();</DIV>
<DIV>&nbsp; iren2-&gt;SetInteractorStyle(iren-&gt;GetInteractorStyle());</DIV>
<DIV>&nbsp; Ren2 = vtkRenderer::New();<BR>&nbsp; qVTK2-&gt;GetRenderWindow()-&gt;AddRenderer(Ren2);</DIV>
<DIV>&nbsp;...........</DIV>
<DIV>&nbsp;...........</DIV>
<DIV>&nbsp;...........</DIV>
<DIV>vtkProperty* ipwProp = vtkProperty::New();</DIV>
<DIV>vtkImagePlaneWidget* ipw = vtkImagePlaneWidget::New();</DIV>
<DIV>&nbsp;</DIV>
<DIV>ipw-&gt;SetKeyPressActivationValue('x');<BR>&nbsp;ipw-&gt;RestrictPlaneToVolumeOn();<BR>&nbsp;ipw-&gt;GetPlaneProperty()-&gt;SetColor(1,0,0);<BR>&nbsp;ipw-&gt;SetTexturePlaneProperty(ipwProp);<BR>&nbsp;ipw-&gt;SetResliceInterpolateToNearestNeighbour();<BR>&nbsp;ipw-&gt;SetInput(reader-&gt;GetOutput());<BR>&nbsp;ipw-&gt;SetPlaneOrientationToYAxes();<BR>&nbsp;ipw-&gt;SetSliceIndex(30);<BR>&nbsp;ipw-&gt;DisplayTextOn();</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; vtkLookupTable *table2 =vtkLookupTable::New();<BR>&nbsp; table2-&gt;SetRange(0, 2000);&nbsp; </DIV>
<DIV>&nbsp; table2-&gt;SetValueRange(0.0, 1.0);&nbsp; <BR>&nbsp; table2-&gt;SetSaturationRange(0.0, 0.0);&nbsp; <BR>&nbsp; table2-&gt;SetRampToLinear();<BR>&nbsp; table2-&gt;Build();</DIV>
<DIV>&nbsp; vtkImageMapToColors *colorMap = vtkImageMapToColors::New();<BR>&nbsp;&nbsp;colorMap-&gt;SetInput(ipw-&gt;GetResliceOutput());<BR>&nbsp; colorMap-&gt;SetLookupTable(table2);</DIV>
<DIV>&nbsp;vtkImageActor&nbsp; *actor2 =vtkImageActor::New();<BR>&nbsp; actor2-&gt;SetInput(colorMap-&gt;GetOutput());</DIV>
<DIV>&nbsp; Ren2-&gt;AddActor(actor2); </DIV>
<DIV>&nbsp; QObject::connect(spinBox_2,SIGNAL(valueChanged(int)),verticalScrollBar_2,SLOT(setValue(int)));<BR>&nbsp; QObject::connect(verticalScrollBar_2,SIGNAL(valueChanged(int)),spinBox_2,SLOT(setValue(int)));<BR>&nbsp; verticalScrollBar_2-&gt;setValue(ipw-&gt;GetSliceIndex());</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; ScrollBarCallback *callback=ScrollBarCallback::New();<BR>&nbsp; callback-&gt;SetScrollBar(verticalScrollBar_2);<BR>&nbsp; callback-&gt;SetImagePlaneWidget(ipw);<BR>&nbsp; callback-&gt;SetInteractor(iren2);</DIV>
<DIV><BR>&nbsp; iren2-&gt;GetInteractorStyle()-&gt;AddObserver(vtkCommand::InteractionEvent,callback);<BR>&nbsp; iren2-&gt;Start();<BR>...............</DIV>
<DIV>...............</DIV>
<DIV>...............</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;When i used this ScrollBarCallback class, QVTKInteractor showed:</DIV>
<DIV>&nbsp;&nbsp; QVTKInteractor (02A60E78): QVTKInteractor cannot control the event loop.And the scrollbar can not control the the slice(setsliceindex())&nbsp;. </DIV>
<DIV>&nbsp;&nbsp; I&nbsp;did not know&nbsp;which code was wrong,or maybe i should use &nbsp; vtkEventQtSlotConnect. I just did a try,using </DIV>
<DIV>vtkEventQtSlotConnect::Connect(imageplane-&gt;SetSliceIndex(int),vtkCommand::NoEvent,slider,SIGNAL(valueChanged(int)));</DIV>
<DIV>it also didn't work,maybe it was wrong.</DIV>
<DIV>&nbsp;</DIV>
<DIV>I was confused for more than a month.</DIV>
<DIV>Thanks for your&nbsp;advice and help.&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV></div>