<div dir="ltr"><div><div><div><div><div><div><div><div><div><div>Hi Muhammad,<br><br></div>QVTKWidget uses its own sub-classed vtkRenderWindowInteractor <br></div>(QVTKInteractor) for proper control of the Qt event loop. When you<br></div>set up your vtkImageViewer2 in your QApplication, try the following:<br><br></div>vtkRenderWindow* renwin = engine->GetRenderWindow();<br></div>imageViewer->SetRenderWindow( renwin);<br></div><div></div>imageViewer->SetupInteractor( renwin->GetInteractor() ); // make the link between Qt and vtkImageViewer<br>imageViewer->SetInput( reader->GetOutput() );<br></div>renwin->Render();<br><br></div>there is no need to call Start() on the interactor: QApplication will initialize the event loop.<br><br></div>best regards,<br></div>Dean<br><div><div><div><div><div><div><div><div><div><div><br></div></div></div></div></div></div></div></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Feb 23, 2016 at 4:16 AM, Muhammad Jawad <span dir="ltr"><<a href="mailto:softplanner@gmail.com" target="_blank">softplanner@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Dear all,<div><br></div><div>I am using Qt 5.4 with vtk 6.2 on windows. I am facing some problem using QVtkWidget with vtkRenderWindowInteractor, It never returns once vtkrenderwindowinteractor->start() call. </div><div><br></div><div>When I close the QVtkWidget or main application but it still running in background.</div><div><br></div><div>my code is:</div><div><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(128,0,128)"><br></span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(128,0,128)">vtkImageViewer2</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">*</span><span style="color:rgb(0,0,0)">imageViewer</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkImageViewer2</span><span style="color:rgb(0,0,0)">::</span><span style="color:rgb(0,0,0)">New</span><span style="color:rgb(0,0,0)">();</span></pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">imageViewer</span><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">-></span><span style="font-family:arial,sans-serif;font-style:italic;color:rgb(0,0,0)">SetInputData</span><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">(reader-</span><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">></span><span style="font-family:arial,sans-serif">GetOutput</span><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">());</span><br></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:arial,sans-serif;color:rgb(128,0,128)"><br></span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:arial,sans-serif;color:rgb(128,0,128)">vtkRenderWindowInteractor</span><span style="font-family:arial,sans-serif;color:rgb(192,192,192)"> </span><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">*</span><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">renderWindowInteractor</span><span style="font-family:arial,sans-serif;color:rgb(192,192,192)"> </span><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">=</span><span style="font-family:arial,sans-serif;color:rgb(192,192,192)"> </span><span style="font-family:arial,sans-serif;color:rgb(128,0,128)">vtkRenderWindowInteractor</span><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">::</span><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">New</span><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">();</span><br></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:arial,sans-serif;color:rgb(0,0,0)"><br></span></pre><pre style="margin-top:0px;margin-bottom:0px"><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)">imageViewer</span><span style="color:rgb(0,0,0)">-></span><span style="font-style:italic;color:rgb(0,0,0)">SetupInteractor</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(0,0,0)">renderWindowInteractor</span><span style="color:rgb(0,0,0)">);</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:arial,sans-serif;color:rgb(128,0,128)">QVtkWidget</span><span style="font-family:arial,sans-serif;color:rgb(192,192,192)"> </span><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">*</span><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">engine</span><span style="font-family:arial,sans-serif;color:rgb(192,192,192)"> </span><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">=</span><span style="font-family:arial,sans-serif;color:rgb(192,192,192)"> </span><span style="font-family:arial,sans-serif;color:rgb(128,128,0)">new</span><span style="font-family:arial,sans-serif;color:rgb(192,192,192)"> </span><span style="font-family:arial,sans-serif;color:rgb(128,0,128)">QVtkWidget</span><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">(</span><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">);</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">engine</span><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">-></span><span style="font-family:arial,sans-serif;font-style:italic;color:rgb(0,0,0)">SetRenderWindow</span><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">(</span><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">imageViewer</span><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">-></span><span style="font-family:arial,sans-serif;font-style:italic;color:rgb(0,0,0)">GetRenderWindow</span><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">());</span><span style="font-family:arial,sans-serif;color:rgb(192,192,192)"> </span><span style="font-family:arial,sans-serif;color:rgb(0,128,0)">//</span><span style="font-family:arial,sans-serif;color:rgb(192,192,192)"> </span><span style="font-family:arial,sans-serif;color:rgb(0,128,0)">make</span><span style="font-family:arial,sans-serif;color:rgb(192,192,192)"> </span><span style="font-family:arial,sans-serif;color:rgb(0,128,0)">the</span><span style="font-family:arial,sans-serif;color:rgb(192,192,192)"> </span><span style="font-family:arial,sans-serif;color:rgb(0,128,0)">link</span><span style="font-family:arial,sans-serif;color:rgb(192,192,192)"> </span><span style="font-family:arial,sans-serif;color:rgb(0,128,0)">between</span><span style="font-family:arial,sans-serif;color:rgb(192,192,192)"> </span><span style="font-family:arial,sans-serif;color:rgb(0,128,0)">VTK</span><span style="font-family:arial,sans-serif;color:rgb(192,192,192)"> </span><span style="font-family:arial,sans-serif;color:rgb(0,128,0)">and</span><span style="font-family:arial,sans-serif;color:rgb(192,192,192)"> </span><span style="font-family:arial,sans-serif;color:rgb(0,128,0)">QT</span><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">renderWindowInteractor</span><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">-></span><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">SetRenderWindow</span><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">(</span><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">imageViewer</span><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">-></span><span style="font-family:arial,sans-serif;font-style:italic;color:rgb(0,0,0)">GetRenderWindow</span><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">());</span><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)">engine</span><span style="color:rgb(0,0,0)">-></span><span style="color:rgb(0,0,0)">show</span><span style="color:rgb(0,0,0)">();</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)">imageViewer</span><span style="color:rgb(0,0,0)">-></span><span style="font-style:italic;color:rgb(0,0,0)">GetRenderWindow</span><span style="color:rgb(0,0,0)">()-></span><span style="font-style:italic;color:rgb(0,0,0)">Render</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">();</span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)"><br></span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)">//renderWindowInteractor</span><span style="color:rgb(0,0,0)">-></span><span style="font-style:italic;color:rgb(0,0,0)">Initialize</span><span style="color:rgb(0,0,0)">();</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)">engine</span><span style="color:rgb(0,0,0)">-></span><span style="font-style:italic;color:rgb(0,0,0)">GetRenderWindow</span><span style="color:rgb(0,0,0)">()-></span><span style="font-style:italic;color:rgb(0,0,0)">GetInteractor</span><span style="color:rgb(0,0,0)">()-></span><span style="font-style:italic;color:rgb(0,0,0)">Start</span><span style="color:rgb(0,0,0)">();</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,128,0)">//renderWindowInteractor->Start();</span></pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px">cerr<span style="color:rgb(0,0,0)"><<</span><span style="color:rgb(0,128,0)">"exit"</span><span style="color:rgb(0,0,0)">;</span></pre></pre><pre style="margin-top:0px;margin-bottom:0px"><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"><br></span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">How I can return from vtkRenderWindowInteractor->Start() function ?</span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"><br></span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"><br></span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">Thanks.</span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"><br></span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"><br></span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">--</span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">Muhammad Jawad </span></pre></pre></div></div>
<br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" 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" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br></div>