[vtkusers] QVTKWidget with Qt 4.0.0
Jens
jens-devel at gmx.de
Tue Aug 2 09:35:01 EDT 2005
Hi
Here is an small example app using QVTKWidget.
Tested with the CVS of vtk and cmake.
Replace the CMakeList.txt of GUISupport/Qt with the attached one to compile
QVTKWidget for Qt4.
Greetings
Jens
Am Dienstag, 2. August 2005 14:57 schrieb Adam Hooper:
> On Mon, 2005-08-01 at 22:22 -0400, Jim Gerlach wrote:
> > What is the procedure to compile QVTKWidget plugin with Qt 4.0.0 in
> > Visual Studio .NET 2003? Is there something in CMakeLists.txt that
> > needs to be changed in order to compile? I also noticed there is
> > Q4VTKWidgetPlugin.cxx (and header). Does this replace
> > QVTKWidgetPlugin.cxx?
>
> Yeah, I recently had this problem and solved it -- check out
> http://public.kitware.com/pipermail/vtkusers/2005-July/081054.html for
> the problem and solution. Note: you'll need to compile CMake from CVS
> (or at least use the FindQt* modules from CVS).
>
> If you can get the QVTKWidget to actually *run* without crashing
> complaining about a QPaintDevice, please let me know
> (<http://public.kitware.com/pipermail/vtkusers/2005-July/081083.html>).
-------------- next part --------------
# we need Qt
SET(QT_MAX_VERSION "4.9.9")
FIND_PACKAGE(Qt REQUIRED)
# set up sources to build
SET ( QVTKLibSrcs
QVTKWidget.cxx
vtkEventQtSlotConnect.cxx)
SET ( QVTKMocHeaders
QVTKWidget.h)
SET ( QVTKExtraMoc
vtkEventQtSlotConnect.cxx)
SET ( PluginMocHeaders
QVTKWidget.h)
# CMake apparently doesn't do this automatically
IF(QT_INST_MAJOR_VERSION GREATER 3)
SET ( PluginLibSrcs
QVTKWidget.cxx
Q4VTKWidgetPlugin.cxx)
SET_SOURCE_FILES_PROPERTIES(Q4VTKWidgetPlugin.cxx PROPERTIES
OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/QVTKWidget.xpm)
ELSE(QT_INST_MAJOR_VERSION GREATER 3)
SET ( PluginLibSrcs
QVTKWidget.cxx
Q3VTKWidgetPlugin.cxx)
SET_SOURCE_FILES_PROPERTIES(Q3VTKWidgetPlugin.cxx PROPERTIES
OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/QVTKWidget.xpm)
ENDIF(QT_INST_MAJOR_VERSION GREATER 3)
# help CMake with this generated moc file
SET_SOURCE_FILES_PROPERTIES(vtkEventQtSlotConnect.cxx PROPERTIES
OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/moc_vtkEventQtSlotConnect.cxx)
# assuming a Qt dll, otherwise plugins aren't possible
ADD_DEFINITIONS(-DQT_DLL)
# check for a multithreaded Qt dll
IF(QT_QT_LIBRARY MATCHES "mt")
ADD_DEFINITIONS(-DQT_THREAD_SUPPORT)
ENDIF(QT_QT_LIBRARY MATCHES "mt")
# include Qt
INCLUDE_DIRECTORIES ( ${QT_INCLUDE_DIR} )
INCLUDE_DIRECTORIES ( ${CMAKE_CURRENT_BINARY_DIR} )
# includes for Qt4
INCLUDE_DIRECTORIES ( ${QT_INCLUDES} )
QT_WRAP_CPP ( QVTK QVTKLibMocSrcs ${QVTKMocHeaders} )
QT_WRAP_CPP ( QVTK QVTKLibExtraMocSrcs ${QVTKExtraMoc} )
QT_WRAP_CPP ( QVTKWidgetPlugin PluginMocSrcs ${PluginMocHeaders} )
ADD_LIBRARY(QVTK ${QVTKLibSrcs} ${QVTKLibMocSrcs})
IF(QT_INST_MAJOR_VERSION GREATER 3)
# libs for Qt4
TARGET_LINK_LIBRARIES( QVTK
${QT_QTGUI_LIBRARY}
${QT_QTCORE_LIBRARY}
${QT_QTOPENGL_LIBRARY}
vtkRendering
vtkGraphics
vtkImaging
vtkCommon)
ELSE(QT_INST_MAJOR_VERSION GREATER 3)
# libs for Qt < 4
TARGET_LINK_LIBRARIES( QVTK
${QT_QT_LIBRARY}
vtkRendering
vtkGraphics
vtkImaging
vtkCommon
)
ENDIF(QT_INST_MAJOR_VERSION GREATER 3)
# build plugin by default
# even if VTK is built as static libraries (for convenience)
SET(BUILD_QVTK_PLUGIN ON)
# don't build plugin on systems that require dependents to be shared (PIC actually)
IF(NOT BUILD_SHARED_LIBS)
IF(CMAKE_SYSTEM MATCHES "HP-UX.*")
SET(BUILD_QVTK_PLUGIN OFF)
ENDIF(CMAKE_SYSTEM MATCHES "HP-UX.*")
ENDIF(NOT BUILD_SHARED_LIBS)
IF(BUILD_QVTK_PLUGIN)
ADD_DEFINITIONS(-DQT_PLUGIN)
# add QVTK plugin from sources
# stand-alone as it doesn't depend on QVTK library
ADD_LIBRARY ( QVTKWidgetPlugin
SHARED
${PluginLibSrcs}
${PluginMocSrcs}
)
IF(QT_INST_MAJOR_VERSION GREATER 3)
# libs for Qt4
TARGET_LINK_LIBRARIES( QVTKWidgetPlugin
${QT_QTGUI_LIBRARY}
${QT_QTCORE_LIBRARY}
${QT_QTOPENGL_LIBRARY}
vtkRendering
vtkImaging
vtkGraphics
vtkFiltering
vtkCommon )
ELSE(QT_INST_MAJOR_VERSION GREATER 3)
# libs for Qt < 4
TARGET_LINK_LIBRARIES( QVTKWidgetPlugin
${QT_QT_LIBRARY}
vtkRendering
vtkImaging
vtkGraphics
vtkFiltering
vtkCommon
)
ENDIF(QT_INST_MAJOR_VERSION GREATER 3)
ELSE(BUILD_QVTK_PLUGIN)
MESSAGE(STATUS "Will not build QVTK plugin because VTK isn't build as shared libraries")
ENDIF(BUILD_QVTK_PLUGIN)
# Configure the VTKConfigQt.cmake support file.
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/VTKConfigQt.cmake.in
${VTK_BINARY_DIR}/VTKConfigQt.cmake @ONLY IMMEDIATE)
# install rules
IF(BUILD_QVTK_PLUGIN)
# install at /plugins/designer allows one to set their designer plugin path
# in the designer preferences to the vtk-install/plugins directory.
IF(NOT VTK_INSTALL_QT_DIR)
SET(VTK_INSTALL_QT_DIR /plugins/designer)
ENDIF(NOT VTK_INSTALL_QT_DIR)
IF(NOT VTK_INSTALL_NO_RUNTIME)
INSTALL_TARGETS( ${VTK_INSTALL_QT_DIR} QVTKWidgetPlugin )
ENDIF(NOT VTK_INSTALL_NO_RUNTIME)
IF ( UNIX )
ADD_CUSTOM_TARGET( install-qtplugin
install -m 777 -o root ${VTK_BINARY_DIR}/bin/libQVTKWidgetPlugin.so ${QTDIR}/${VTK_INSTALL_QT_DIR}
DEPENDS ${VTK_BINARY_DIR}/bin/libQVTKWidgetPlugin.so )
ENDIF ( UNIX )
ENDIF(BUILD_QVTK_PLUGIN)
IF(NOT VTK_INSTALL_NO_DEVELOPMENT)
INSTALL_FILES( ${VTK_INSTALL_INCLUDE_DIR} .h ${QVTKLibSrcs})
INSTALL_FILES( ${VTK_INSTALL_LIB_DIR} FILES ${VTK_BINARY_DIR}/VTKConfigQt.cmake )
ENDIF(NOT VTK_INSTALL_NO_DEVELOPMENT)
IF(NOT VTK_INSTALL_NO_LIBRARIES)
INSTALL_TARGETS( ${VTK_INSTALL_LIB_DIR} QVTK )
ENDIF(NOT VTK_INSTALL_NO_LIBRARIES)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: QVTKWidget-Example.tar.gz
Type: application/x-tgz
Size: 5352 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050802/a3444b5f/attachment.bin>
More information about the vtkusers
mailing list