[vtkusers] tutorial: msvc2010 + vtk6.0.0 + qt5.0.1

Flavio Simonetti flaviosime at gmail.com
Fri Jul 12 04:07:09 EDT 2013


Hi community
I would use Qvtkwidget ( VTK 6.0.0 + QT5) with mscv2010 and after several
test I found a way to install and use it. Here I send a short explanation
(with a lot of steps) to help who need it.
 Something can change on your system.
This tutorial is refer to WIN7 32-64 bit system.

1 --- install ------
mcvc2010 (not express)
cmake 2.8.11

download and install this QT5 .exe form QT page:
    qt-windows-opensource-5.1.0-msvc2010-x86-offline (default settings)
    qt-vs-addin-1.2.2-opensource

download VTK 6 from GIT : git://vtk.org/VTK.git
Release on vtk page haven't QT5 setting in GUISupport/QT/CMakelists.txt and
other file.

Set QT system variables:
  C:\Qt\Qt5.1.0\5.1.0\msvc2010\bin; C:\Qt\Qt5.1.0\5.1.0\msvc2010\lib;

--- VTK ------------------------

Before use cmake with Vtk I made some changes in cmakelists.txt files:

 C:/VTK6/.....GuiSupport/qt/cmakelists.txt
    .../qt/QtOpenGL/cmakelists.txt
   .../qt/QTsql/cmakelists.txt
   .../qt /QTwebkit/cmakelists.txt
   .../Views/Qt/cmakelists.txt
   .../ Rendering/Qt/cmakelists.txt

Where I commented lines which refer to QT4 because cmake try to find QT4
also if I never install it.
THis WAy:

#if(VTK_QT_VERSION VERSION_GREATER "4")
    find_package(Qt5Designer REQUIRED QUIET)
    add_definitions(${Qt5Designer_DEFINITIONS})
    include_directories(${Qt5Designer_INCLUDE_DIRS})
    qt5_wrap_cpp(PluginMocSrcs ${PluginMocHeaders})
    set(QT_LIBRARIES ${Qt5Designer_LIBRARIES})
  # else()
    # add_definitions(-DQT_PLUGIN)
    # include_directories(${QT_QTDESIGNER_INCLUDE_DIR})
    # qt4_wrap_cpp(PluginMocSrcs ${PluginMocHeaders})
    # set(QT_LIBRARIES ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
  # endif()

---- build cmake -----
Open cmake and set Directory as usual.
Use 'Configure ' and select visual studio 10 as compiler.
After check varialbes:
-  build shared lib ON
-  testing OFF
-  vtk group qt ON
- other if you need

'Configure' again.
Set  manually  all the required paths:
 C:/Qt/Qt5.1.0/5.1.0/msvc2010/lib/cmake/Qt5XXX ....

If configure is done, 'Generate'.
At this point a lot this warning are visibile:

  "CMake Warning (dev) in Rendering/Qt/CMakeLists.txt:
  Policy CMP0020 is not set: Automatically link Qt executables to qtmain
  target on Windows. Run "cmake --help-policy CMP0020" for policy details.
  Use the cmake_policy command to set the policy and suppress this warning.
  This warning is for project developers. Use -Wno-dev to suppress it."

Don't worry about them :)

----- msvc2010 ----

Open the vc project and compile a Release win32.
Sometimes some projects fails. It's usually a linker error .Control
dependencies of those projects to solve this problem .

FInally I compiled all except QTOpenGL because 'GL_DOUBLE' have a twice
definition: in GL/gl.h( as double) and in qopengl.h (as GLfloat) but I don't
need it in my case.

Here the output (in italian sorry):
------ Start: vtkGUISupportQtOpenGL, : Release Win32 ------
...
  1>  QVTKGraphicsItem.cxx
  1>C:/Qt/Qt5.1.0/5.1.0/msvc2010/include\QtCore/qstring.h(824): 
        warning C4127: espressione condizionale costante
  1>C:/Qt/Qt5.1.0/5.1.0/msvc2010/include\QtCore/qobject_impl.h(133): 
          warning C4512: ' QtPrivate::QSlotObjectBase': impossibile generare
un operatore di assegnazione
   1>   C:/Qt/Qt5.1.0/5.1.0/msvc2010/include\QtCore/qobject_impl.h(107):
       vedere la dichiarazione di 'QtPrivate::QSlotObjectBase'
    1>C:/Qt/Qt5.1.0/5.1.0/msvc2010/include\QtCore/qhash.h(72): warning
C4127: espressione condizionale costante
  1>C:/Qt/Qt5.1.0/5.1.0/msvc2010/include\QtCore/qhash.h(81):
            warning C4127: espressione condizionale costante
  1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\GL/gl.h(55):
          error C2371: 'GLdouble': ridefinizione. Tipi di base differenti.
  1>  C:/Qt/Qt5.1.0/5.1.0/msvc2010/include\QtGui/qopengl.h(97):
           vedere la dichiarazione di 'GLdouble'
  1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\GL/gl.h(201): 
      warning C4005: 'GL_DOUBLE': ridefinizione macro
  1>   C:/Qt/Qt5.1.0/5.1.0/msvc2010/include\QtGui/qopengl.h(94):
    vedere la precedente definizione di 'GL_DOUBLE'
   1>  QVTKWidget2.cxx
   1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\GL/gl.h(55):
    error C2371: 'GLdouble': ridefinizione. Tipi di base differenti.
  1> C:/Qt/Qt5.1.0/5.1.0/msvc2010/include\QtGui/qopengl.h(97): vedere la
dichiarazione di 'GLdouble'
  1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\GL/gl.h(201):
     warning C4005: 'GL_DOUBLE': ridefinizione macro
  1> C:/Qt/Qt5.1.0/5.1.0/msvc2010/include\QtGui/qopengl.h(94): 
    vedere la precedente definizione di   'GL_DOUBLE'


set VTK dir in win7 sys path :
 C:\VTK6.0.0-build\bin\Release;
 C:\VTK6.0.0-build\lib\Release

copy QVTKWidgetPlugin.dll in qtdesign directory
C:\Qt\Qt5.1.0\5.1.0\msvc2010\plugins\designer
this make the widget visible in qtdesigner


---- cmakelist project -------------

to make a project which use qt+vtk i use this cmakelists.rxt:

cmake_minimum_required(VERSION 2.8)
 
PROJECT(RenderWindowsQt)
 
find_package(VTK REQUIRED)
include(${VTK_USE_FILE})

find_package(Qt5Widgets REQUIRED QUIET)
  include_directories(${Qt5Widgets_INCLUDE_DIRS})
  add_definitions(${Qt5Widgets_DEFINITIONS})
  set(QT_LIBRARIES ${Qt5Widgets_LIBRARIES})

include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) 

file(GLOB UI_FILES *.ui)
file(GLOB QT_WRAP *.h)
file(GLOB CXX_FILES *.cxx)

QT5_WRAP_UI(UISrcs ${UI_FILES})
QT5_WRAP_CPP(MOCSrcs ${QT_WRAP})
add_executable(RenderWindowsQt MACOSX_BUNDLE ${CXX_FILES} ${UISrcs}
${MOCSrcs})
 
if(VTK_LIBRARIES)
  if(${VTK_VERSION} VERSION_LESS "6")
    target_link_libraries(RenderWindowsQt ${VTK_LIBRARIES} QVTK)
  else()
    target_link_libraries(RenderWindowsQt ${VTK_LIBRARIES})
  endif()
else()
  target_link_libraries(RenderWindowsQt ${VTK_LIBRARIES} ${QT_LIBRARIES})
endif()

This set up all .lib from vtk and qt : if you need to exclude something
watch in  project options: linker-> input 


And that's all!!

   Flavio Simonetti



--
View this message in context: http://vtk.1045678.n5.nabble.com/tutorial-msvc2010-vtk6-0-0-qt5-0-1-tp5721922.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list