<br>
Hi Xiaopeng,<br><br>Please post some of the error messages <br>to the mailing list.<br><br>We can&#39;t help you much if we can&#39;t see the <br>error messages...<br><br><br>&nbsp;&nbsp;&nbsp; Thanks<br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Luis<br><br><br>
-----------------------------------------------------------<br><div class="gmail_quote">2010/7/12 Xiaopeng Yang <span dir="ltr">&lt;<a href="mailto:yxp233@postech.ac.kr">yxp233@postech.ac.kr</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">









<div link="blue" vlink="purple" lang="EN-US">

<div>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">Hi Luis,</span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">&nbsp;</span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">Thanks very much for your help. I tried again according to your
suggestion, but I met many errors. Attached is my header file of SimpleView,
where shall I modify? And at the main code, what I need to do is that just
changing them to </span></p><div class="im">

<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">&nbsp; this-&gt;reader =
ReaderType::New();</span></p>

<p class="MsoNormal" style="text-indent: 10.5pt;"><span style="font-size: 10pt; font-family: DotumChe;">this-&gt;connector
= FilterType::New();</span><span style="font-size: 10pt; font-family: DotumChe;"></span></p>

</div><p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">Is there anything else I shall modify in the main code?</span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">&nbsp;</span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">&nbsp;</span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">Attached is the header file:</span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">&nbsp;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">#ifndef</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> SimpleView_H</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">#define</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> SimpleView_H</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">#include</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> <span style="color: rgb(163, 21, 21);">&quot;vtkSmartPointer.h&quot;</span>&nbsp;&nbsp;&nbsp;
<span style="color: green;">// Required for smart pointer internal ivars.</span></span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">#include</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> <span style="color: rgb(163, 21, 21);">&lt;QMainWindow&gt;</span></span></p>


<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(163, 21, 21);">&nbsp;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">QT_BEGIN_NAMESPACE</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">class</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> QAction;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">class</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> QLabel;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">class</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> QMenu;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">class</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> QScrollArea;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">class</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> QScrollBar;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">QT_END_NAMESPACE</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: green;">// Forward Qt class declarations</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">class</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> Ui_SimpleView;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: green;">// Forward VTK class declarations</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">class</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> vtkQtTableView;</span></p>


<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">class</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> SimpleView : <span style="color: blue;">public</span>
QMainWindow</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp; Q_OBJECT</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">public</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">:</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp; <span style="color: green;">//
Constructor/Destructor</span></span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp; SimpleView(); </span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp; ~SimpleView();</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">public</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> slots:</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp; <span style="color: blue;">virtual</span> <span style="color: blue;">void</span> slotOpenFile();</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp; <span style="color: blue;">virtual</span> <span style="color: blue;">void</span> slotExit();</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">protected</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">:</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">protected</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> slots:</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">private</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">:</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp;
vtkSmartPointer&lt;vtkQtTableView&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
TableView;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp;&nbsp;&nbsp; </span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp; <span style="color: green;">// Designer form</span></span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp; Ui_SimpleView *ui;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">};</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&nbsp;</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">#endif</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">
<span style="color: green;">// SimpleView_H</span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: green;"></span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: green;">&nbsp;</span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">&nbsp;</span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">&nbsp;</span></p>

<div style="border-style: solid none none; border-color: rgb(181, 196, 223) -moz-use-text-color -moz-use-text-color; border-width: 1pt medium medium; padding: 3pt 0in 0in;">

<p class="MsoNormal"><b><span style="font-size: 10pt;" lang="ZH-CN">发件人</span></b><b><span style="font-size: 10pt;">:</span></b><span style="font-size: 10pt;"> Luis Ibanez
[mailto:<a href="mailto:luis.ibanez@kitware.com" target="_blank">luis.ibanez@kitware.com</a>] <br>
<b><span lang="ZH-CN">发送时间</span>:</b> Thursday, June 17, 2010 11:53 PM<br>
<b><span lang="ZH-CN">收件人</span>:</b> Xiaopeng Yang<br>
<b><span lang="ZH-CN">抄送</span>:</b> <a href="mailto:vtkusers@vtk.org" target="_blank">vtkusers@vtk.org</a>; itk<br>
<b><span lang="ZH-CN">主题</span>:</b> Re: [vtkusers] About DICOM loading with VTK,
ITK and QT</span></p>

</div><div><div></div><div class="h5">

<p class="MsoNormal">&nbsp;</p>

<p class="MsoNormal" style="margin-bottom: 12pt;"><br>
Hi Xiaopeng,<br>
<br>
It is likely that the source of the error is that<br>
you are instantiating ITK objects inside your<br>
constructor, but not associating them to <br>
member variables of the &quot;SimpleView&quot; class.<br>
<br>
Therefore, these ITK objects will be destroyed<br>
by the time you get to the closing bracket of<br>
your class constructor (the end of scope).<br>
<br>
<br>
The typical solution here,<br>
is that you should make:</p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">&nbsp; ReaderType::Pointer
reader;</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">&nbsp; FilterType::Pointer
connector;</span></p>

<p class="MsoNormal">&nbsp;</p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">to be member variables of your
class (move them to </span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">declaration of the SimpleView
class in your header file)</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">and instantiate them in the
constructor as</span></p>

<p class="MsoNormal">&nbsp;</p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">&nbsp; this-&gt;reader =
ReaderType::New();</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">&nbsp; this-&gt;connector =
FilterType::New();</span></p>

<p class="MsoNormal"><br>
<br>
In this way, they will stay alive for the lifetime<br>
of the SimpleView class.<br>
<br>
<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp; Regards,<br>
<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Luis<br>
<br>
<br>
-----------------------------------------------------------------</p>

<div>

<p class="MsoNormal">On Tue, Jun 15, 2010 at 10:06 AM, Xiaopeng Yang &lt;<a href="mailto:yxp233@postech.ac.kr" target="_blank">yxp233@postech.ac.kr</a>&gt; wrote:</p>

<div>

<div>

<div>

<div>

<p class="MsoNormal">Dear
VTK users,</p>

<p class="MsoNormal">&nbsp;</p>

<p class="MsoNormal">&nbsp;I
made a simple UI with QT for loading a DICOM image by ITK and visualize it by
VTK. Even I successfully debugged the code, but when I ran the executable file,
errors occurred: &ldquo;An unhandled win32 exception occurred in SimpleView.exe
[448]&rdquo;. Could you help me to check whether there is any problem in my code?</p>

<p class="MsoNormal">&nbsp;</p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">SimpleView::SimpleView() </span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">{</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">&nbsp; <span style="color: blue;">this</span>-&gt;ui
= <span style="color: blue;">new</span> Ui_SimpleView;</span></p>

<p class="MsoNormal" style="text-indent: 10.5pt;"><span style="font-size: 10pt; font-family: DotumChe; color: blue;">this</span><span style="font-size: 10pt; font-family: DotumChe;">-&gt;ui-&gt;setupUi(<span style="color: blue;">this</span>);</span></p>


<p class="MsoNormal" style="text-indent: 10.5pt;">&nbsp;</p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe; color: green;">//Define ITK DICOM
loader</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">&nbsp; <span style="color: blue;">typedef</span>
itk::Image &lt;<span style="color: blue;">unsigned</span> <span style="color: blue;">short</span>, 2&gt; ImageType;</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">&nbsp; <span style="color: blue;">typedef</span>
itk::ImageFileReader&lt;ImageType&gt;ReaderType;</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">&nbsp;</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">&nbsp; <span style="color: green;">//Connect
ITK to VTK</span></span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">&nbsp; <span style="color: blue;">typedef</span>
itk::ImageToVTKImageFilter&lt;ImageType&gt;FilterType;</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">&nbsp;</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">&nbsp; ReaderType::Pointer reader
= ReaderType::New();</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">&nbsp; FilterType::Pointer
connector = FilterType::New();</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">&nbsp; reader-&gt;SetFileName(<span style="color: rgb(163, 21, 21);">&quot;C:/Documents and Settings/edt/Desktop/QT
Test3/ImageViewer/DICOM/portal47.dcm&quot;</span>);</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">&nbsp;
connector-&gt;SetInput(reader-&gt;GetOutput());</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">&nbsp;</span></p>

<p class="MsoNormal" style="text-indent: 10.5pt;"><span style="font-size: 10pt; font-family: DotumChe;">vtkImageViewer
*viewer = vtkImageViewer::New();</span></p>

<p class="MsoNormal" style="text-indent: 10.5pt;"><span style="font-size: 10pt; font-family: DotumChe;">&nbsp;</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe; color: green;">&nbsp; </span><span style="font-size: 10pt; font-family: DotumChe; color: blue;">this</span><span style="font-size: 10pt; font-family: DotumChe;">-&gt;ui-&gt;qvtkWidget_2-&gt;SetRenderWindow(viewer-&gt;GetRenderWindow());</span></p>


<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">&nbsp;
viewer-&gt;SetupInteractor(<span style="color: blue;">this</span>-&gt;ui-&gt;qvtkWidget_2-&gt;GetRenderWindow()-&gt;GetInteractor());</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">&nbsp;
viewer-&gt;SetInput(connector-&gt;GetOutput());</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">&nbsp; viewer-&gt;Render();</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">&nbsp;
viewer-&gt;SetColorLevel(255);</span></p>

<p class="MsoNormal" style="text-indent: 10.5pt;"><span style="font-size: 10pt; font-family: DotumChe;">viewer-&gt;SetColorWindow(128);</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">&nbsp; </span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">&nbsp; connect(<span style="color: blue;">this</span>-&gt;ui-&gt;actionOpenFile, SIGNAL(triggered()), <span style="color: blue;">this</span>, SLOT(slotOpenFile()));</span></p>


<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">&nbsp; connect(<span style="color: blue;">this</span>-&gt;ui-&gt;actionExit, SIGNAL(triggered()), <span style="color: blue;">this</span>, SLOT(slotExit()));</span></p>


<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">};</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">&nbsp;</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: DotumChe;">&nbsp;</span></p>

<p class="MsoNormal"><span style="font-size: 10pt;">Thanks.</span></p>

<p class="MsoNormal"><span style="font-size: 10pt;">&nbsp;</span></p>

<p class="MsoNormal"><span style="font-size: 10pt;">Xiaopeng</span></p>

</div>

</div>

</div>

</div>

<p class="MsoNormal" style="margin-bottom: 12pt;"><br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a></p>

</div>

<p class="MsoNormal">&nbsp;</p>

</div></div></div>

</div>


</blockquote></div><br>