STEP ONE
- Download ITK, VTK, QT source code
- CMake: http://www.cmake.org/cmake/resources/software.html
- ITK: http://www.itk.org/ITK/resources/software.html
- VTK: http://www.vtk.org/VTK/resources/software.html
- QT: http://qt-project.org/downloads
- Note: In this tutorial, the used tool version numbers are listed here:
- cmake-2.8.10.2-win32-x86.exe
- InsightToolkit-4.2.1
- VTK5.10.1
- Qt4.8.4
- the main purpose of using cmake is taking the advantage of building a cross platform program
STEP TWO
- prons:
- organized and the binary codes for different platforms can be separated from each other
- easy maintenance
- easy upgrade
STEP THREE (main part of this tutorial)
<<build a 32bit environment>>
- build QT -> already done, leave this directory alone!!
- build ITK
- CMAKE PART
- using CMake to build the visual studio 2010 32-bit environment
- fill up the paths of source code and binary
- click the "Configure" button
- choose "Visual Studio 2010" and "Use default native compilers" and then click "Finish"
- wait a few minutes....
- Generally speaking, the message will show "Configuring done" like this snapshot:
- Remember: Just leave default setting, because those unchecked items are not being used here for now.
- click "Generate" button and wait for the "Generate done" message
- VISUAL STUDIO PART
- go to the build directory, e.g. "C:\itk\itk-4.2.1\vs10"
- open "ITK.sln"
- build them all under the Debug mode and Release mode
- wait a few minutes....( at lease one hour, depend on your machine )
- NOTE HERE: building on the release mode is necessary, because if we want to combine ITK and QT together, visual studio project need to be under the Release mode!!This is a tricky part.
- Until all the project being built successfully, the building process is over.
- build VTK( careful! )
- CMAKE PART
- using CMake to build the visual studio 2010 32-bit environment
- fill the paths of source code and binary up
- click the "Configure" button
- choose "Visual Studio 2010" and "Use default native compilers" and then click "Finish"
- wait a few minutes....
- Generally speaking, the message will show "Configuring done" like this snapshot:
- BE CAREFUL:
- CHECK BUILD_EXAMPLES ( for QT + VTK project test )
- CHECK BUILD_SHARED_LIBS ( for VTK work with QT )
- CHECK VTK_USE_QT ( for VTK library to build QT-related components)
- CHECK VTK_USE_GUISUPPORT ( you need to check the "Advanced" item first in order to see this setting)
- click "Configure" button AGAIN!!
- if everything goes well, then the result should look like this:
- click "Generate" button and wait for the "Generate done" message
- VISUAL STUDIO PART
- go to the build directory, e.g. "C:\vtk\VTK5.10.1\vs10"
- open "VTK.sln"
- build them all under the Release mode Release mode Release mode
- wait a few minutes....( the needed time depends on your machine )
- NOTE HERE: building on the release mode is necessary, because if we want to combine VTK and QT together, visual studio project need to be under the Release mode!!This is a tricky part.
- Until all the project being built successfully, the building process is over.
- QT SETUP PART
- go to "C:\vtk\VTK5.10.1\vs10\bin\Release" and check if there are two file name QVTKWidgetPlugin.lib and QVTKWidgetPlugin.dll
- (Note: if they are NOT there, then you must have not check BUILD_SHARED_LIBS)
- Copy QVTKWidgetPlugin.lib and QVTKWidgetPlugin.dll from "C:\vtk\VTK5.10.1\vs10\bin\Release" to C:\Qt\4.x.x\plugins\designer
- if everything goes well, then open the QT designer. You will find the VTK WINDOW WIDGET at the bottom of the qt widget list like this snapshot:
- ENVIRONMENT VARIABLE SETUP PART ( THE MOST IMPORTANT!!!!! )
- Add a new environment variable: QTDIR = C:\Qt\4.X.X (or whatever VERSION you installed QT)
- Append the environment variable PATH to add
- C:\Qt\4.8.4\bin
- C:\vtk\VTK5.10.1\vs10\bin\Release
STEP FOUR
- check whether the environment being setup correctly or not
- check ITK + VTK + QT
- check ITK + QT
- check VTK + QT
- in the VTK source code, there are a few examples can be used for checking under the Example folder
- Tutorial Projects
- EasyView
- SimpleView
- Qtevents
- qtimageviewer
- QtVTKRenderWindows
- EventQtSlotConnect
References and other useful links
- VTK/Tutorials/QtSetup http://www.vtk.org/Wiki/VTK/Tutorials/QtSetup
- VTK + QT examples http://www.vtk.org/Wiki/VTK/Examples/Cxx#Qt
2014/02/25 update
Thanks a bunch, man! I have to start a project that uses EXACTLY this configuration...I was stuck an entire week, trying to configure all togheter...Your guide really saved my life (that's be only, complete guide about this topic on the entire Net)! :-)
回覆刪除Keep the good work with your blog!
so glad to help!
回覆刪除Thanks for your help. I think this is the only post about ITK + VTK + QT on Window 7 64bit and Visual Studio 2010 Pro 32bit project. Its really very help full . Thanks Again.
回覆刪除where to add add QTDIR = C:\Qt\4.X.X??
回覆刪除thank you.
電腦->右鍵內容->進階系統設定->環境變數->系統變數->新增QTDIR, 然後輸入你的qt目錄位置!!
刪除Hi thanks for the tutorial. I have one problem when run debug/release for itk.sln. It said AllBuild unsuccess? It is okay or I miss do something?
回覆刪除I am not pretty sure what the problem is
刪除Could you be more specific on that?
Nice post! Just wondering if Qt 5.2 and VTK 6.1 can be built in a same or similar way? Can you foresee any potential issue? Thanks
回覆刪除Thanks for your help, here is how I configure Qt5.2 and VTK6.1:
刪除http://linzhang-vision.blogspot.co.uk/2014/04/configure-vtk-61-qt-52-under-win7-32bit.html
Awesome post! Thanks a bunch :D
回覆刪除Hello,
回覆刪除this is a great post how ever I have a question. I'm new on QT and VTK and I saw your posts from qt forum as well. I'm working on a project that I need to open a dcm file via qt. But I counldn't figure it out. I was wondering if you can help. Nothing online is working. Thank you
You mean, open a dcm file "directly" via qt?
回覆刪除Qt has no API for opening a dcm file.
The easiest and solid way is opened by ITK and then render it by VTK with showing widget of QT
First of all thank you for your answer! I have the code to open with ITK (C++ code). And now I need to combine the code with VTK and show it QT widget. Can you help me with that? What I need is basically to have an interface to open dicom files that I have in my computer and have a tool bar at the bottom to slide through the slices. Thank you
回覆刪除