[vtkusers] tutorial to use VTK with Qt

Ashish Singh mrasingh at gmail.com
Tue Oct 17 13:04:54 EDT 2006


Hi,

I am a newbie in VTK and Qt. For some time now,I have been trying to use VTK
with Qt but faced a lot of problems getting started and configuring them. In
the end, it worked(thanks to Anja Ende,Clinton Stimpson and everyone who
helped me get started). I am writing down the procedure to get VTK to work
with Qt in visual studio 2005 environment. Hopefully this document will help
other newbies save a lot of time.

I have tested the following procedure with MS Visual Studio 2005
Professional on Windows XP Pro X64.

1). Install and get Qt working as per the instructions here:
http://qtnode.net/wiki/Qt4_with_Visual_Studio
This works fine and you can start using Qt with visual studio(for those who
just want to use Qt with Visual Studio, this is how we do it!)

2). Install and configure VTK using Cmake with (a) VTK_USE_GUISUPPORT option
and (b) VTK_USE_QVTK option, set to 'ON'
If Qt is installed after VTK, you will need to reconfigure VTK to find Qt.

3).Now it's time to test the configuration with a code which uses both Qt
and VTK. You can try it with the example in VTK source(
../Examples/GUI/Qt/Imageviewer). Copy this code(only the cxx file) to a new
directory.

4) I use 'qmake' to generate build files. The method to build this example
using qmake is:
(a) open visual studio command prompt, go to the directory containing the
cxx file and type: qmake -project
this makes a '.pro' file. Open this file in an editor and modify it as
below-
----
######################################################################
# Automatically generated by qmake (2.00a) Wed Oct 11 17:14:01 2006
######################################################################

TEMPLATE = vcapp # this was originally 'app' modify it to 'vcapp'
TARGET +=
DEPENDPATH += .
INCLUDEPATH += . # here include the path to all the directories containing
the header files
LIBS += # add this line and include all the libraries(Qt and VTK) needed for
the application

# Input
SOURCES += main.cxx
-----
(b)Save the .pro file and run qmake from the command prompt again. This will
generate a '.vcproj' file. Open this file in visual studio and build it
there. If you included all the libraries and include paths, this should
build and run perfectly.

I used qmake for building, because I didn't know how to do it with Cmake.
But if the experts here can throw light on that it would help many. Also if
someone knows of any other way(probably easier and smarter) to use Qt with
VTK, please add to this document.

Thanks,
Ashish
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20061017/3c79a78e/attachment.htm>


More information about the vtkusers mailing list