VTK与QT相融合
作者:互联网
VTK可视化的小能手。
QT开发GUI大法器。
将他们结合,可以发挥大作用。话不多说,上代码
.h变量定义
QVTKOpenGLWidget* pVTKWidget; vtkEventQtSlotConnect* vtkQtConn;
.cpp构造函数
ui->setupUi(this); pVTKWidget = new QVTKOpenGLWidget(this); ui->stackedWidget->addWidget(pVTKWidget); pRenderer = vtkSmartPointer<vtkRenderer>::New(); pRenderWindow = pVTKWidget->GetRenderWindow(); pRenWinInterActor = pRenderWindow->GetInteractor();
vtkSmartPointer<vtkJPEGReader> reader = vtkSmartPointer<vtkJPEGReader>::New();
reader->SetFileName("d:/h1.jpg");
reader->Update();
vtkSmartPointer<vtkImageActor> actor1 = vtkSmartPointer<vtkImageActor>::New();
actor1->GetMapper()->SetInputConnection(reader->GetOutputPort());
pRenderer->AddActor(actor1);
pRenderer->SetBackground(1,0,0);
pRenderWindow->AddRenderer(pRenderer);
pRenderWindow->Render();
执行效果
标签:pVTKWidget,pRenderer,QT,pRenderWindow,VTK,融合,vtkSmartPointer,reader,New 来源: https://www.cnblogs.com/larkin-cn/p/16450115.html