[vtkusers] QVTKInteractor problem
Luis Roberto P. Paula
luisrpp at gmail.com
Wed Feb 11 12:12:01 EST 2009
Hi Clint,
It is working now.
I just added this at the end of the constructor: QDialog::exec();
I was calling exec outside the class and It wasn't the exec implemented by
QDialog.
Thanks for your help!
Luis
On Wed, Feb 11, 2009 at 2:01 PM, Clinton Stimpson <clinton at elemtech.com>wrote:
>
> Are you showing this dialog on another thread?
>
> Clint
>
> Clinton Stimpson wrote:
>
>>
>> From what you've given, I can't tell what your problem is. Forget the
>> second event loop idea, its impossible and wouldn't solve anything. You've
>> already got one running, and that's good enough.
>> How about using a debugger and following where the execution goes from
>> QVTKWidget::mousePressEvent.
>>
>> Clint
>>
>> Luis Roberto P. Paula 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<mailto:
>>> 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>
>>> <mailto: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 <http://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
>>>
>>>
>>>
>>>
>>
>> _______________________________________________
>> 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/be68a469/attachment.htm>
More information about the vtkusers
mailing list