[Insight-developers] problem in creating UI with cmake and visual studio 2010

Luis Ibanez luis.ibanez at kitware.com
Mon May 16 22:04:36 EDT 2011


Hi John

Please find attached a minimal example
of how to combine ITK with QT.

You simple need to add the proper
configuration in the CMakeLists.txt file,
and create your Visual Studio project
FROM CMake.

Do not create the project from inside
Visual Studio.

---------------------------------

The CMakeLists.txt file should be
something like:

cmake_minimum_required(VERSION 2.8)

PROJECT(RenderWindowUI)

FIND_PACKAGE(ITK)
INCLUDE(${ITK_USE_FILE})

FIND_PACKAGE(Qt4 REQUIRED)
INCLUDE(${QT_USE_FILE})

# support for out-of-source build
INCLUDE_DIRECTORIES(
  ${CMAKE_CURRENT_BINARY_DIR} #this is where ui_SimpleViewUI.h is generated
  ${CMAKE_CURRENT_SOURCE_DIR}
)

# Set your files and resources here
SET(SimpleViewSrcs RenderWindowUI.cxx SimpleViewUI.cxx)
SET(SimpleViewUI SimpleViewUI.ui)
SET(SimpleViewHeaders SimpleViewUI.h)

QT4_WRAP_UI(UISrcs ${SimpleViewUI})
QT4_WRAP_CPP(MOCSrcs ${SimpleViewHeaders} )

SOURCE_GROUP("Resources" FILES
  ${SimpleViewUI}
)

SOURCE_GROUP("Generated" FILES
  ${UISrcs}
  ${MOCSrcs}
)

ADD_EXECUTABLE( RenderWindowUI ${SimpleViewSrcs} ${UISrcs} ${MOCSrcs})
TARGET_LINK_LIBRARIES( RenderWindowUI  ${ITK_LIBRARIES} )


     Luis


-----------------------
On Sun, May 15, 2011 at 3:03 PM, john smith
<mkinsightdeveloper at gmail.com> wrote:
> Hello,
>
> I have already used ITK many times for several medical image processing
> applications, but it is my first time to create my own UI for my
> application. This UI I want to be very simple. Just to open and display a 3D
> image and use one button to make some type of processing over the image, and
> finally display the result again. I am using windows 7 (64bit), with visual
> studio 2010 and cmake to configure my project. At this point starts my
> problem. Well to configure my source code and then generate my .sln file I
> must use cmake, and I cannot do this from visual studio. To create my UI, I
> use Qt, which has been added-in visual studio. I do not really know how
> could I with the press of a button, to run cmake and then run visual studio
> to take my results? I would appreciate if someone could give me some advice.
>
> Thanks in advance
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-developers
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Qt-VTK-3D-Widget-Example.zip
Type: application/zip
Size: 3589 bytes
Desc: not available
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20110516/d6155856/attachment.zip>


More information about the Insight-developers mailing list