[vtkusers] QT + VKT + ITK + VS2008

G G greenlander1986 at gmail.com
Wed Apr 27 10:29:23 EDT 2011


So my CMakeLists.txt is here...


CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
IF(COMMAND CMAKE_POLICY)
  CMAKE_POLICY(SET CMP0003 NEW)
ENDIF(COMMAND CMAKE_POLICY)

PROJECT(Watershed)

# Find ITK.
FIND_PACKAGE(ITK)
IF(ITK_FOUND)
  INCLUDE(${ITK_USE_FILE})
ELSE(ITK_FOUND)
  MESSAGE(FATAL_ERROR "Cannot build without ITK.  Please set ITK_DIR.")
ENDIF(ITK_FOUND)

IF(NOT VTK_BINARY_DIR)
FIND_PACKAGE(VTK)
IF(NOT VTK_DIR)
  MESSAGE(FATAL_ERROR "Nastavte prosim VTK_DIR.")
ENDIF(NOT VTK_DIR)
INCLUDE(${VTK_USE_FILE})
ENDIF(NOT VTK_BINARY_DIR)



IF(WIN32)
    SET(QT_USE_QTMAIN TRUE)
ENDIF(WIN32)


# use what QVTK built with
SET(QT_QMAKE_EXECUTABLE ${VTK_QT_QMAKE_EXECUTABLE} CACHE FILEPATH "")
SET(QT_MOC_EXECUTABLE ${VTK_QT_MOC_EXECUTABLE} CACHE FILEPATH "")
SET(QT_UIC_EXECUTABLE ${VTK_QT_UIC_EXECUTABLE} CACHE FILEPATH "")
FIND_PACKAGE(Qt4)
IF(QT_USE_FILE)
  INCLUDE(${QT_USE_FILE})
ELSE(QT_USE_FILE)
  SET(QT_LIBRARIES   ${QT_QT_LIBRARY})
ENDIF(QT_USE_FILE)


SET (SRCS
  main.cxx
)

# Set your files and resources here
SET(WatershedUI WatershedWindow.ui)
SET(WatershedResources Icons/icons.qrc)

# Use the include path and library for Qt that is used by VTK.
INCLUDE_DIRECTORIES(
        ${QT_INCLUDE_DIR}
        ${CMAKE_CURRENT_BINARY_DIR}
        ${CMAKE_CURRENT_SOURCE_DIR}
)

QT4_WRAP_UI(UI_SRCS ${WatershedUI})
QT4_WRAP_CPP(MOC_SRCS WatershedWindow.h)
QT4_ADD_RESOURCES(RCC_SRCS ${WatershedResources})
SET(SRCS ${SRCS} ${MOC_SRCS} WatershedWindow.cxx
                             WatershedWindow.h
                             WatershedLoading.cxx
                             WatershedLoading.h
                             WatershedCompute.cxx
                             WatershedCompute.h
                             WatershedImageInteraction.cxx
                             WatershedImageInteraction.h
                             WatershedParameters.cxx
                             WatershedParameters.h)

SOURCE_GROUP("Generated Resources"
  REGULAR_EXPRESSION "(qrc.*)|(moc.*)|(ui.*)"
)

SOURCE_GROUP("Resources" FILES
  ${WatershedUI}
  ${WatershedResources}
  ${EXE_ICON}
)

IF(WIN32)
 SET(GUI_TYPE WIN32)
ENDIF(WIN32)

ADD_EXECUTABLE( WatershedSegmentation ${SRCS} ${UI_SRCS} ${RCC_SRCS})

TARGET_LINK_LIBRARIES( WatershedSegmentation
  QVTK
  ${QT_LIBRARIES}
  vtkRendering
  vtkGraphics
  vtkIO
  vtkCommon
  vtkHybrid
  vtkImaging
  vtkFiltering

  ITKAlgorithms ITKBasicFilters ITKCommon ITKIO
)


When I run CMake, it wrote this...

Check for working C compiler using: Visual Studio 9 2008
Check for working C compiler using: Visual Studio 9 2008 -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working CXX compiler using: Visual Studio 9 2008
Check for working CXX compiler using: Visual Studio 9 2008 -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Looking for Q_WS_X11
Looking for Q_WS_X11 - not found.
Looking for Q_WS_WIN
Looking for Q_WS_WIN - found
Looking for Q_WS_QWS
Looking for Q_WS_QWS - not found.
Looking for Q_WS_MAC
Looking for Q_WS_MAC - not found.
Found Qt-Version 4.7.2 (using C:/Qt/4.7.2/bin/qmake.exe)
Configuring done

Then I build my project solution in release mode.
But When I open my exe file, it open gui and console window...
I am hopeless

2011/4/27 Michael Jackson <mike.jackson at bluequartz.net>

> There is most likely nothing wrong with your builds of ITK and VTK. Leave
> those alone for now.
> --
> Mike Jackson <www.bluequartz.net>
>
> On Apr 27, 2011, at 10:22 AM, G G wrote:
>
> > Do you mean delete all files from my project? or I should delete and
> recompiled VTK, ITK, etc.?
> > I try to delete my project at first...
> > Then I write what it do...
> >
> > 2011/4/27 Michael Jackson <mike.jackson at bluequartz.net>
> >   Qt has already done that for you and is taken care of by using the
> following lines in your CMakeLists.txt file:
> >
> > IF (WIN32)
> >  SET (QT_USE_QTMAIN TRUE)
> > ENDIF (WIN32)
> >
> > Of course this assumes you are using CMake to configure your project. The
> QtMain is a static library in the Qt distribution that contains the
> WinMain16 function which then calls your "main()" function.
> >
> > Edit your CMakeLists.txt as I have stated in previous emails. Close
> Visual Studio. Completely delete EVERYTHING from your Build directory and
> reconfigure using CMake. It _should_ work. If it does NOT then either post
> your CMakeLists.txt code, a link to your project or google the qt error that
> you are getting.
> >
> > --
> > Mike Jackson <www.bluequartz.net>
> >
> > On Apr 27, 2011, at 9:52 AM, Lodron, Gerald wrote:
> >
> > > The difference between console mode and gui mode on visual studio is
> that console mode starts the "main" function and that the GUI mode starts
> the "WinMain" function, see
> > >
> > > Main: http://msdn.microsoft.com/en-us/library/acy3edy3(VS.71).aspx
> > > WinMain:
> http://msdn.microsoft.com/en-us/library/ms633559(v=vs.85).aspx
> > >
> > > As the name implies, main is more platform independent and is known on
> Windows, Unix, Linux etc. WinMain is only known by Windows. Qt is platform
> independent and also runs on Linux so WinMain is for Qt bad.
> > >
> > > But you could try to write your Qt conde into a WinMain function i have
> not tested it but it should work, here the signature
> > > int CALLBACK WinMain(
> > >   __in  HINSTANCE hInstance,
> > >   __in  HINSTANCE hPrevInstance,
> > >   __in  LPSTR lpCmdLine,
> > >   __in  int nCmdShow
> > > );
> > >
> > >
> > >
> > > Von: G G [mailto:greenlander1986 at gmail.com]
> > > Gesendet: Mittwoch, 27. April 2011 13:13
> > > An: Lodron, Gerald
> > > Cc: (vtkusers at vtk.org)
> > > Betreff: Re: [vtkusers] QT + VKT + ITK + VS2008
> > >
> > > Thank you very much, I will try it :)
> > > Do you know some article about it? I wrote some thesis and it would be
> nice, if I have some reference for it...
> > >
> > > 2011/4/27 Lodron, Gerald <Gerald.Lodron at joanneum.at>
> > > Qt runs only in console mode, if you want to hide console you can write
> a bat file which starts the exe like this:
> > >
> > > start MyPropgram.exe
> > >
> > > Then the program does not wait for the return value of the
> MyProgram.exe console
> > > best regards
> > >
> > > Von: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] Im
> Auftrag von G G
> > > Gesendet: Mittwoch, 27. April 2011 12:57
> > > An: vtkusers at vtk.org
> > > Betreff: [vtkusers] QT + VKT + ITK + VS2008
> > >
> > > Hi I have some project with QT+VTK+ITK and I compile it in Visual
> Studio 2008. I create solution with CMake. It works fine. But I compile it
> and run. When I run it, I have GUI window and console window. So I have
> question. How to disable console window?
> > >
> > > I think, that it is because of CMake, but I dont know very well.
> > > I tried to used this
> > >
> http://www.qtforum.org/article/18473/tutorial-for-using-qt-with-vtk.html
> > > But when I tried to compile it, it gave me many errors...
> > > Do you know some complete progress, how to compile it?
> > > Or how to disable console window?
> > >
> > > I dont have console window because of it get me qWarning
> > >
> > > QObject::killTimers: timers cannot be stopped from another thread
> > >
> > > when I exit application from console window.
> > > When I exit application from GUI console window freeze :(
> > >
> > > Thank you all for help
> > >
> > > _______________________________________________
> > > Powered by www.kitware.com
> > >
> > > Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> > >
> > > Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> > >
> > > Follow this link to subscribe/unsubscribe:
> > > http://www.vtk.org/mailman/listinfo/vtkusers
> >
> > _______________________________________________
> > Powered by www.kitware.com
> >
> > Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> >
> > Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> >
> > Follow this link to subscribe/unsubscribe:
> > http://www.vtk.org/mailman/listinfo/vtkusers
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110427/fef7f1f4/attachment.htm>


More information about the vtkusers mailing list