I was hoping that calling the Start method of the interactor would help, but in the source file of the QVTKInteractor I found this:<br><br><pre class="fragment"><font size="4">00267   <span class="comment">// Description:</span><br>
<a name="l00268"></a>00268   <span class="comment">// Overloaded start method does nothing.</span><br><a name="l00269"></a>00269   <span class="comment">// Use qApp-&gt;exec() instead.</span></font><br></pre>That is why I think it only works in the <span style="color: rgb(255, 0, 0);">main</span> function. I can not call the qApp-&gt;exec in the constructor of my Dialog class.<br>
<br><br>Luis<br><br><div class="gmail_quote">On Wed, Feb 11, 2009 at 2:55 AM, Luis Roberto P. Paula <span dir="ltr">&lt;<a href="mailto:luisrpp@gmail.com">luisrpp@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Clint,<br><br>In the main window of my application I have a QVTKWidget. I have set some callbacks to detect mouse events and in this window everything is working fine.<br><br>Then I tried to open a second window (QDialog for example) by clicking on a button of the main window. In this second window I have also a QVTKWidget object. I&#39;m displaying an 2D image on it with the vtkImageViewer2 and the zoom control with the mouse wheel is working fine (default action). The problem is with the callback that I have created. In the constructor of my QDialog class it is set like this:<br>

<br>&nbsp;&nbsp; vtkImageInteractionCallback* callback = vtkImageInteractionCallback::New();<br>&nbsp;&nbsp; imageStyle-&gt;AddObserver(vtkCommand::MouseMoveEvent, callback);<br>&nbsp;&nbsp; imageStyle-&gt;AddObserver(vtkCommand::LeftButtonPressEvent, callback);<br>

&nbsp;&nbsp; imageStyle-&gt;AddObserver(vtkCommand::LeftButtonReleaseEvent, callback);<br><br>&nbsp;&nbsp; vtkWidget-&gt;GetRenderWindow()-&gt;GetInteractor()-&gt;SetInteractorStyle(imageStyle);<br><br>None of this events are being captured.<br>

<br>I thought it could be something wrong in the code, but when I tried to load this second window as the main window, everything worked.<br><br>&nbsp;&nbsp; int main(int argc, char *argv[])<br>&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; QApplication app(argc, argv);<br>

<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /*MyGui* mainWindow = new MyGui;<br>&nbsp; &nbsp; &nbsp; mainWindow-&gt;show();*/<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyDialog* dialog = new MyDialog; // HERE IT WORKS, BUT THE DIALOG SHOULD BE PART OF THE MAIN WINDOW.<br>
&nbsp; &nbsp; &nbsp; dialog&gt;show();<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return app.exec();<br>&nbsp;&nbsp; }<br><br>Do you know why this is happening?<br><br>Thanks,<br><font color="#888888">Luis</font><div><div></div><div class="Wj3C7c"><br><br><div class="gmail_quote">
On Wed, Feb 11, 2009 at 2:15 AM, Clinton Stimpson <span dir="ltr">&lt;<a href="mailto:clinton@elemtech.com" target="_blank">clinton@elemtech.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
So which callbacks aren&#39;t working? &nbsp;I don&#39;t see how trying to make another event loop would solve a callback problem.<br>
If its a dialog, why not call exec() on it instead of show() ? &nbsp;exec() will create a temporary local event loop (see QEventLoop).<br>
Also, each thread can only have one event loop active at a time, and all Qt widgets are on the same thread.<br>
<br>
Clint<br>
<br>
Luis Roberto P. Paula wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I have set the second window as a Dialog window and open it as modal. For some reason, the callback for this new window are not being observed.<br>
<br>
On Tue, Feb 10, 2009 at 1:04 AM, Luis Roberto P. Paula &lt;<a href="mailto:luisrpp@gmail.com" target="_blank">luisrpp@gmail.com</a> &lt;mailto:<a href="mailto:luisrpp@gmail.com" target="_blank">luisrpp@gmail.com</a>&gt;&gt; wrote:<br>


<br>
 &nbsp; &nbsp;Hi All,<br>
<br>
 &nbsp; &nbsp;Since QVTKInteractor cannot control the event loop, how do I start<br>
 &nbsp; &nbsp;a second window after the click of a button and make this new<br>
 &nbsp; &nbsp;window to have its own event loop?<br>
<br>
 &nbsp; &nbsp;When the button is clicked, this action is performed:<br>
<br>
 &nbsp; &nbsp; &nbsp;MyWidget* widget = new &nbsp; MyWidget();<br>
 &nbsp; &nbsp; &nbsp;widget-&gt;show();<br>
<br>
 &nbsp; &nbsp;The new window appears, but to make the interactor to work, there<br>
 &nbsp; &nbsp;should be a command like:<br>
<br>
 &nbsp; &nbsp; &nbsp;qApp-&gt;exec();<br>
<br>
 &nbsp; &nbsp;but QT does not allow me to start a new GUI event loop.<br>
<br>
 &nbsp; &nbsp;Does anybody can help me?<br>
<br>
 &nbsp; &nbsp;Thanks,<br>
 &nbsp; &nbsp;Luis<br>
<br>
<br>
------------------------------------------------------------------------<br>
<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><br>
 &nbsp;<br>
</blockquote>
<br>
<br>
</blockquote></div><br>
</div></div></blockquote></div><br>