Hi stackoverflow family
I'm trying to get vtk working with qt. I should admit that I'm a newbie, so go easy. I'm trying to learn c++ for myself and have chosen the following configuration to get me started;
OS: Windows 7 ultimate
toolkit: QT 5.3.2
IDE: QT Creator 3.2.1
VTK: 6.3.0
I downloaded and extracted the VTK to "C:\vtk-6.3.0" on my computer. I followed the instructions given on VTK's website to build VTK with cmake. I gave cmake the location of the source "C:/vtk-6.3.0" and specified a place to build the libraries "C:/vtk/bin".
Thinking everything had gone smoothly, I proceeded with the simplest example I could get away with, an example without a ui. I got the example from here
RenderWindowNoUiFile.cxx
#include <QApplication> #include <vtkSmartPointer.h> #include <vtkSphereSource.h> #include <vtkPolyDataMapper.h> #include <vtkActor.h> #include <vtkRenderWindow.h> #include <vtkRenderer.h> #include <QVTKWidget.h> int main(int argc, char** argv) { QApplication app(argc, argv); QVTKWidget widget; widget.resize( 256, 256 ); vtkSmartPointer<vtkSphereSource> sphereSource = vtkSmartPointer<vtkSphereSource>::New(); vtkSmartPointer<vtkPolyDataMapper> sphereMapper = vtkSmartPointer<vtkPolyDataMapper>::New(); sphereMapper->SetInputConnection( sphereSource->GetOutputPort() ); vtkSmartPointer<vtkActor> sphereActor = vtkSmartPointer<vtkActor>::New(); sphereActor->SetMapper( sphereMapper ); vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New(); renderer->AddActor( sphereActor ); widget.GetRenderWindow()->AddRenderer( renderer ); widget.show(); app.exec(); return EXIT_SUCCESS; } I added my .pro file manually
RenderWindowNoUiFile.pro
QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = RenderWindowNoUiFile TEMPLATE = app SOURCES += RenderWindowNoUiFile.cxx INCLUDEPATH += C:\VTK\bin I observed that qt has underlined all of the header files and when I ran the program and I got the error
Projects\RenderWindowNoUiFile\RenderWindowNoUiFile.cxx:3: error: vtkSmartPointer.h: No such file or directory #include <vtkSmartPointer.h> ^ Please what I'm I doing wrong?
When I searched for any of the header files, I find each in a different location in the "C:\vtk\bin" or "C:\vtk-6.3.0" folder. Please how do I solve this problem? Can I get all of the header files in a single folder so that I can refer to it in the .pro file? For example if I can get all the header files in a directory called "C:\vtk\header", then I can refer to it in my .pro file as INCLUDEPATH += C:\vtk\header
C:\VTK\binis the build folder. The headers will not be there. If you use the INSTALL target to install vtk you will get a folder with the binaries and include.