[vtkusers] QVTKInteractor problem

Luis Roberto P. Paula luisrpp at gmail.com
Wed Feb 11 00:12:44 EST 2009


I was hoping that calling the Start method of the interactor would help, but
in the source file of the QVTKInteractor I found this:

00267   // Description:
00268   // Overloaded start method does nothing.
00269   // Use qApp->exec() instead.

That is why I think it only works in the main function. I can not call the
qApp->exec in the constructor of my Dialog class.


Luis

On Wed, Feb 11, 2009 at 2:55 AM, Luis Roberto P. Paula <luisrpp at gmail.com>wrote:

> Hi Clint,
>
> 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.
>
> 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'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:
>
>    vtkImageInteractionCallback* callback =
> vtkImageInteractionCallback::New();
>    imageStyle->AddObserver(vtkCommand::MouseMoveEvent, callback);
>    imageStyle->AddObserver(vtkCommand::LeftButtonPressEvent, callback);
>    imageStyle->AddObserver(vtkCommand::LeftButtonReleaseEvent, callback);
>
>
> vtkWidget->GetRenderWindow()->GetInteractor()->SetInteractorStyle(imageStyle);
>
> None of this events are being captured.
>
> 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.
>
>    int main(int argc, char *argv[])
>    {
>       QApplication app(argc, argv);
>
>       /*MyGui* mainWindow = new MyGui;
>       mainWindow->show();*/
>
>       MyDialog* dialog = new MyDialog; // HERE IT WORKS, BUT THE DIALOG
> SHOULD BE PART OF THE MAIN WINDOW.
>       dialog>show();
>
>       return app.exec();
>    }
>
> Do you know why this is happening?
>
> Thanks,
> Luis
>
>
> On Wed, Feb 11, 2009 at 2:15 AM, Clinton Stimpson <clinton at elemtech.com>wrote:
>
>>
>> So which callbacks aren't working?  I don't see how trying to make another
>> event loop would solve a callback problem.
>> If its a dialog, why not call exec() on it instead of show() ?  exec()
>> will create a temporary local event loop (see QEventLoop).
>> Also, each thread can only have one event loop active at a time, and all
>> Qt widgets are on the same thread.
>>
>> Clint
>>
>> Luis Roberto P. Paula wrote:
>>
>>> 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.
>>>
>>> On Tue, Feb 10, 2009 at 1:04 AM, Luis Roberto P. Paula <
>>> luisrpp at gmail.com <mailto:luisrpp at gmail.com>> wrote:
>>>
>>>    Hi All,
>>>
>>>    Since QVTKInteractor cannot control the event loop, how do I start
>>>    a second window after the click of a button and make this new
>>>    window to have its own event loop?
>>>
>>>    When the button is clicked, this action is performed:
>>>
>>>      MyWidget* widget = new   MyWidget();
>>>      widget->show();
>>>
>>>    The new window appears, but to make the interactor to work, there
>>>    should be a command like:
>>>
>>>      qApp->exec();
>>>
>>>    but QT does not allow me to start a new GUI event loop.
>>>
>>>    Does anybody can help me?
>>>
>>>    Thanks,
>>>    Luis
>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>> _______________________________________________
>>> 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 VTK FAQ at:
>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>
>>>
>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090211/3060e405/attachment.htm>


More information about the vtkusers mailing list