VTK does not provide anything that would make QT += vtk work in qmake. You’ll have to list libraries that you need by name (like for any other third party package in qmake).
// Create a VTK renderer, render window, and interactor
vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->AddRenderer(renderer);
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
renderWindowInteractor->SetRenderWindow(renderWindow);
// Create a vtkPoints object to hold the well path points
vtkSmartPointer<vtkPoints> points =
vtkSmartPointer<vtkPoints>::New();
// Create a dummy well path
points->InsertNextPoint(0.0, 0.0, 0.0); // Start point
points->InsertNextPoint(10.0, 0.0, 0.0); // Next point
points->InsertNextPoint(20.0, 5.0, 0.0); // Another point
points->InsertNextPoint(30.0, 5.0, -5.0); // Another point
points->InsertNextPoint(40.0, 10.0, -5.0); // End point
// Create a vtkCellArray to hold the lines connecting the points
vtkSmartPointer<vtkCellArray> lines =
vtkSmartPointer<vtkCellArray>::New();
// Create a line connecting each pair of adjacent points
for (vtkIdType i = 0; i < points->GetNumberOfPoints() - 1; i++)
{
vtkSmartPointer<vtkLine> line =
vtkSmartPointer<vtkLine>::New();
line->GetPointIds()->SetId(0, i);
line->GetPointIds()->SetId(1, i + 1);
lines->InsertNextCell(line);
}
// Create a vtkPolyData object to hold the points and lines
vtkSmartPointer<vtkPolyData> polyData =
vtkSmartPointer<vtkPolyData>::New();
polyData->SetPoints(points);
polyData->SetLines(lines);
// Create a mapper and actor for the well path
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputData(polyData);
vtkSmartPointer<vtkActor> actor =
vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
// Add the actor to the renderer
renderer->AddActor(actor);
// Set the background color
renderer->SetBackground(0.1, 0.2, 0.4);
// Initialize and start the interactor
renderWindow->Render();
renderWindowInteractor->Start();
return a.exec();
You’ll have to link to VTK libraries. It looks like you’ll need at least vtkCommonCore, vtkRenderingCore, and vtkRenderingOpenGL2. There may be others as well. I don’t know qmake enough to tell you how to do it, but you’ll have to use the library names I imagine.