Results 1 to 2 of 2

Thread: Tutorial to use Qt with VTK

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2006
    Location
    USA
    Posts
    23
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Tutorial to use Qt with VTK

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Tutorial to use Qt with VTK

    Hi! Thanks for adding tutorials - great work! A better place to put your text would be in the wiki - please add it in the Tutorials and How-tos category. I've added a page for you here: http://wiki.qtcentre.org/index.php?title=VTK_with_Qt . Just edit it and put the text there with some formatting.

Similar Threads

  1. Basic Qt4 tutorial needed
    By pthomas in forum Qt Programming
    Replies: 26
    Last Post: 16th October 2006, 15:11
  2. Interesting tutorial on UI Designer
    By GreyGeek in forum Qt Tools
    Replies: 1
    Last Post: 6th August 2006, 08:43
  3. Can't Compile Tutorial 7
    By Reenen in forum Newbie
    Replies: 10
    Last Post: 9th February 2006, 14:06
  4. Is There any Tutorial for non GUI Tcp Application
    By pilgermann in forum Qt Programming
    Replies: 1
    Last Post: 8th February 2006, 18:12
  5. Where are tutorial 2 code examples?
    By Mariane in forum Newbie
    Replies: 6
    Last Post: 25th January 2006, 15:02

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.