<html>
<head>
<style>
P
{
margin:0px;
padding:0px
}
body
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body><div style="text-align: left;">Hello Matthias,<br><br>I have never used the QtSlotAdaptor but there is another simple way to do what u want.<br><br>You can use Qts signal-slot mechanism.<br><br>You need to create a class with the Q_OBJECT macro ,in a slot of this class put the itk functionality, create a QPushButton and an object of that class and connect the buttons signal clicked() to that slot.<br><br>#ifnded myclass_h<br>#define myclass_h<br><br>#include "itkMedianImageFilter.h"<br>#include "qstring.h"<br>#include "itkImage.h"<br>#include "qfiledialog.h"<br><br>class myclass<br>{<br>Q_OBJECT<br>typedef itk::Image&lt;short int ,2&gt;InputImageType;<br>typedef itk::Image&lt;short int ,2&gt;OutputImageType;<br><br>public:<br>&nbsp;<br>public slots:<br>&nbsp;&nbsp;&nbsp; void myslot()<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; typedef itk::ImageFileReader&lt;InputImageType&gt; readertype;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; readertype::Pointer reader=readertype::New();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; typedef itk::ImageFileWriter&lt;OutputImageType&gt; writertype;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; writertype::Pointer writer=writertype::New();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; typedef itk::MedianImageFilter &lt;InputImageType, OutputImageType&gt;FilterType;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FilterType::Pointer filter=FilterType::New()<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; QString filename;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; filename=QFileDialog::getOpenFileName();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; reader-&gt;SetFileName(filename.latin1());<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; filename=QFileDialog::getSaveFileName();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; writer-&gt;SetFileName(filename.latin1());&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; filter-&gt;SetInput(reader-&gt;GetOutput());<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; writer-&gt;SetInput(filter-&gt;GetOutput());<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; filter-&gt;Update();<br>&nbsp;&nbsp;&nbsp; }<br><br>};<br>#endif<br></div><br>and in ur main.ccp file: <br>(i use qt 3.2.1 , it would be a little different in Qt 4 )<br><br>#include &lt;qapplication.h&gt;<br>#include "myclass.h"<br>#include &lt;qpushbutton.h&gt;<br><br>int main( int argc, char **argv )<br>{<br>QApplication a( argc, argv );<br>QPushButton&nbsp; button;<br>a.setMainWidget(&amp;button);&nbsp;&nbsp;&nbsp; <br>myclass median;<br><br>connect(button,SIGNAL(clicked()),median,SLOT(myslot()));<br><br>button.show();<br>return a.exec();<br>}<br><br>Note that all objects created with New() will be deleted at the end of myslot(). If u dont want that u should declare a smart pointer in the header file:<br><br>typedef itk::ImageFileReader&lt;InputImageType&gt; readertype;<br>readertype::Pointer reader=NULL;<br><br>and initialize it inside myslot()<br>readertype::New();<br><br>Also note that since myclass is now a Q_OBJECT it needs moc and in your CMakeLists.txt you should add<br><br>SET(myProject_MOC_SRCS<br>&nbsp;myclass.h<br>&nbsp;)<br><br>Hope the above works havent tried it.<br><br>Plato.<br><br><hr id="stopSpelling">&gt; Date: Sat, 9 Dec 2006 14:35:28 +0100<br>&gt; From: mebert@uni-koblenz.de<br>&gt; To: insight-users@itk.org<br>&gt; Subject: [Insight-users] Qt itk filter<br>&gt; <br>&gt; Hi everyone,<br>&gt; <br>&gt; i am new to this mailing list, so first of all: hello :)<br>&gt; <br>&gt; i try to get a simple qt-itk example to work, but i got some problems<br>&gt; launching my filter using a qt button.<br>&gt; i dont know if its the right way i try to do this:<br>&gt; <br>&gt; 1.) i create a median filter (according to the example in<br>&gt; ItkSoftwareGuide):<br>&gt; <br>&gt;   typedef itk::MedianImageFilter &lt;InputImageType, OutputImageType&gt;<br>&gt; FilterType;<br>&gt;   FilterType::Pointer filter = FilterType::New();<br>&gt; <br>&gt; 2.) i create a simple qt-button:<br>&gt; <br>&gt;   QPushButton medianFilterButton("Median Filter", &amp;mainWidget);<br>&gt;   medianFilterButton.setGeometry(horizontalPosition, 20, buttonWidth,<br>&gt; buttonHeight);<br>&gt; <br>&gt; 3.) i use the qt-itk-adaptor (guess this is wrong):<br>&gt; <br>&gt;   typedef itk::QtSlotAdaptor&lt;FilterType&gt; SlotAdaptorType;<br>&gt;   SlotAdaptorType slotAdaptor;<br>&gt;   slotAdaptor.SetCallbackFunction(filter, &amp; FilterType::Update);<br>&gt;   QObject::connect(&amp;medianFilterButton, SIGNAL(clicked()), &amp;slotAdaptor,<br>&gt; SLOT(Slot()));<br>&gt; <br>&gt; so here are my questions:<br>&gt; <br>&gt; how do i launch my median filter using a qt-button? i need to set the<br>&gt; input for the filter and the writer doing something like this:<br>&gt; <br>&gt;   filter-&gt;SetInput(reader-&gt;GetOutput());<br>&gt;   writer-&gt;SetInput(filter-&gt;GetOutput());<br>&gt; <br>&gt; but thats not the way i want to do it. i just want this to happen after<br>&gt; pushing the button.<br>&gt; can anyone explain me how i figure out which filter has which slots? i<br>&gt; am a bit confused about this ...<br>&gt; <br>&gt; if u need more code to understand what i mean, please let me know!<br>&gt; <br>&gt; thanks for help,<br>&gt; <br>&gt; Matthias<br>&gt; _______________________________________________<br>&gt; Insight-users mailing list<br>&gt; Insight-users@itk.org<br>&gt; http://www.itk.org/mailman/listinfo/insight-users<br><br /><hr />Call friends with PC-to-PC calling -- FREE <a href='http://get.live.com/messenger/overview' target='_new'>Try it now!</a></body>
</html>