[Insight-users] question regarding QT - ITK connection

Sergio Aguirre sergio.aguirre at gmail.com
Tue Jul 14 14:13:23 EDT 2009


Luis

Thank you! Just as a note, I modified the following lines as well...

Line 60
                  m_MemberFunctionUnsignedInt(0),

Lines 98-105
  /** Slot to be connected to Qt Signals. */
  void Slot(int value)
  {
  if( m_MemberFunctionUnsignedInt )
    {
    ((*m_This).*(m_MemberFunctionUnsignedInt))(value);
    }
  }

It works great now,

Sergio

On Tue, Jul 14, 2009 at 9:41 AM, Luis Ibanez <luis.ibanez at kitware.com>wrote:

> Hi Sergio,
>
>
> As the error message states:
>
>
> The QtSlotAdaptor classs has no definition available for
> a SetCallbackFunction() where the function takes "unsigned int"
>  as an argument.
>
>
> The current options are:
>
>                  void, int, and double
>
> See lines 50-57    in    itkQtAdaptor.h:
>
> class QtSlotAdaptor : public QtTranslator
> {
>   typedef  void (T::*TMemberFunctionVoidPointer)();
>   typedef  void (T::*TMemberFunctionIntPointer)(int);
>   typedef  void (T::*TMemberFunctionDoublePointer)(double);
>
>
> You need to insert
>
>   typedef  void (T::*TMemberFunctionUnsignedIntPointer)(unsigned int);
>
> in line 55,
>
> and then insert
>
>
>   /** Specify the callback function. */
>   void SetCallbackFunction(T* object,
>                            TMemberFunctionUnsignedIntPointer
> memberFunction)
>     {
>       m_This = object;
>       m_MemberFunctionUnsignedInt = memberFunction;
>     }
>
> in line 72,
>
> and then insert
>
>   TMemberFunctionUnsignedIntPointer     m_MemberFunctionUnsignedInt;
>
> in lines 121.
>
>
> NOTE, all the lines number are given *before* insertions.
>
>
>
>      Regards,
>
>
>           Luis
>
>
>
> ------------------------------------------------------------------------------
> On Mon, Jul 13, 2009 at 8:47 PM, Sergio Aguirre <sergio.aguirre at gmail.com>wrote:
>
>> Hello everyone.
>>
>> I have been slowly getting the hang of QT and ITK, After a few days I
>> successfully was able to compile and run the QTITK example located at
>> http://public.kitware.com/cgi-bin/viewcvs.cgi/QtITK/?root=InsightApplications
>>
>> The small app loads and image and shows colors depending of the progress
>> it takes when going through a filter. Also it displays a progress bar. I am
>> using 'curvatureflowimagefilter' to test the connections.
>>
>> I now would like to use a slider to set the SetNumberofIterations int
>> variable of the filter from the GUI. Unfortunately I get the message below.
>>
>> I believe I am close as I was able to start the filter using the QTSlider
>> - sliderMoved function to trigger the file reading and filtering by calling
>> the Update function.
>>
>> Any suggestions would be handy. Full code is attached and code snippet is
>> below.
>>
>> Thank you
>>
>> Sergio
>>
>>
>>   QWidget qb;
>>   qb.resize(620,200);
>>
>>   const int buttonHeight =  30;
>>   const int buttonWidth  = 100;
>>   const int buttonSpace  = 100;
>>
>>   int horizontalPosition =  60;
>>
>>   QPushButton  bb( "Start", &qb );
>>   bb.setGeometry( horizontalPosition, 20, buttonWidth, buttonHeight );
>>
>>   horizontalPosition += buttonWidth + buttonSpace;
>>
>>   QtLightIndicator  cc( &qb, "State" );
>>   cc.setGeometry( horizontalPosition, 20, buttonWidth, buttonHeight );
>>   cc.Modified();
>>
>>   horizontalPosition += buttonWidth + buttonSpace;
>>
>>   QPushButton  qt( "Quit", &qb );
>>   qt.setGeometry( horizontalPosition, 20, buttonWidth, buttonHeight );
>>
>>   QtProgressBar qs( &qb, "Progress");
>>   qs.setGeometry( 10, 60, 600, 30 );
>>
>>   QSlider sl(Qt::Horizontal, &qb);
>>   sl.setRange(1, 100);
>>   sl.setValue(10);
>>   sl.setGeometry(100, 110, 400, 60);
>>
>>   // Connect the progress bar to the ITK processObject
>>   qs.Observe( filter.GetPointer() );
>>   qs.Observe( reader.GetPointer() );
>>
>>
>>   typedef QtSlotAdaptor<FilterType> SlotAdaptorType;
>>   SlotAdaptorType slotAdaptor1;
>>   // Connect the adaptor to a method of the ITK filter
>>   slotAdaptor1.SetCallbackFunction( filter, & FilterType::Update );
>>   // Connect the adaptor's Slot to the Qt Widget Signal
>>   QObject::connect( &bb, SIGNAL(clicked()), &slotAdaptor1, SLOT(Slot()) );
>>
>>   typedef QtSlotAdaptor<FilterType> SlotAdaptorType;
>>   SlotAdaptorType slotAdaptor2;
>>   // Connect the adaptor to a method of the ITK filter
>>   slotAdaptor2.SetCallbackFunction( filter, &
>> FilterType::SetNumberOfIterations );
>>   // Connect the adaptor's Slot to the Qt Widget Signal
>>   QObject::connect( &sl, SIGNAL(sliderMoved(int)), &slotAdaptor2,
>> SLOT(Slot()) );
>>
>>
>> ********************* COMPILE OUTPUT
>> *********************************************
>>
>> linux-vk5n:/home/echopixel/Desktop/engine/code/epx01 # make
>> [ 25%] Building CXX object CMakeFiles/epx01.dir/epx.cxx.o
>> /home/echopixel/Desktop/engine/code/epx01/src/epx.cxx: In function ‘int
>> main(int, char**)’:
>> /home/echopixel/Desktop/engine/code/epx01/src/epx.cxx:81: warning:
>> deprecated conversion from string constant to ‘char*’
>> /home/echopixel/Desktop/engine/code/epx01/src/epx.cxx:90: warning:
>> deprecated conversion from string constant to ‘char*’
>> /home/echopixel/Desktop/engine/code/epx01/src/epx.cxx:113: error: no
>> matching function forcall to
>> ‘QtSlotAdaptor<itk::CurvatureFlowImageFilter<itk::Image<float, 2u>,
>> itk::Image<float, 2u> >
>> >::SetCallbackFunction(itk::SmartPointer<itk::CurvatureFlowImageFilter<itk::Image<float,
>> 2u>, itk::Image<float, 2u> > >&, void
>> (itk::FiniteDifferenceImageFilter<itk::Image<float, 2u>, itk::Image<float,
>> 2u> >::*)(unsigned int))’
>> /home/echopixel/Desktop/engine/code/epx01/src/itkQtAdaptor.h:67: note:
>> candidates are: void QtSlotAdaptor<T>::SetCallbackFunction(T*, void
>> (T::*)()) [with T = itk::CurvatureFlowImageFilter<itk::Image<float, 2u>,
>> itk::Image<float, 2u> >]
>> /home/echopixel/Desktop/engine/code/epx01/src/itkQtAdaptor.h:76:
>> note:                 void QtSlotAdaptor<T>::SetCallbackFunction(T*, void
>> (T::*)(int)) [with T = itk::CurvatureFlowImageFilter<itk::Image<float, 2u>,
>> itk::Image<float, 2u> >]
>> /home/echopixel/Desktop/engine/code/epx01/src/itkQtAdaptor.h:85:
>> note:                 void QtSlotAdaptor<T>::SetCallbackFunction(T*, void
>> (T::*)(double)) [with T = itk::CurvatureFlowImageFilter<itk::Image<float,
>> 2u>, itk::Image<float, 2u> >]
>> make[2]: *** [CMakeFiles/epx01.dir/epx.cxx.o] Error 1
>> make[1]: *** [CMakeFiles/epx01.dir/all] Error 2
>> make: *** [all] Error 2
>>
>>
>> _____________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.itk.org/mailman/listinfo/insight-users
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090714/2064112d/attachment.htm>


More information about the Insight-users mailing list