美文网首页
QVTKInteractor cannot control th

QVTKInteractor cannot control th

作者: 药柴 | 来源:发表于2018-09-03 17:04 被阅读0次

在结合使用Qt和VTK的时候,采用QVTKOpenGLWidget控件作为结合两者的接口,在Qt界面上创建了一个可以显示vtk图形的窗口。
为了使用这个窗口,假定窗口名为openGLWidget,用以下代码获得了窗口内的一个renderer并初始化了窗口。

vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
vtkNew<vtkGenericOpenGLRenderWindow> window;
ui.openGLWidget->SetRenderWindow(window);
ui.openGLWidget->GetRenderWindow()->AddRenderer(renderer);
ui.openGLWidget->show();
ui.openGLWidget->GetInteractor()->Initialize();
ui.openGLWidget->GetInteractor()->Start();

发现vtk会自动开启一个警告窗口,提示

QVTKInteractor cannot control the event loop

[vtkusers] Problem with checkerWidget in VTK+QT页面中找到了答案。原来QVTKOpenGLWidget会在创建时完成Interactor创建和开启,保证其对窗口的控制,因此

ui.openGLWidget->GetInteractor()->Initialize();
ui.openGLWidget->GetInteractor()->Start();

这两句话是不必要的。
删除这两句话后,程序不再产生vtk错误窗口。

相关文章

网友评论

      本文标题:QVTKInteractor cannot control th

      本文链接:https://www.haomeiwen.com/subject/xiliwftx.html