[vtkusers] QT + VKT + ITK + VS2008

Michael Jackson mike.jackson at bluequartz.net
Wed Apr 27 09:31:22 EDT 2011


> Las time I had to fight with that, I had to change the name of the "main" function for "WinMain".

NO, Ignore that. In your CMakeLists.txt file you need the following set of commands to properly find Qt4 and set it up for use:

 # ------------------------------------------------------------------------------
   #  Qt 4 Section
   # ------------------------------------------------------------------------------
   # by default only QtCore and QtGui modules are enabled
   # other modules must be enabled like this:  
   IF (WIN32)
       SET (QT_USE_QTMAIN TRUE)
   ENDIF (WIN32)

   # this command finds Qt4 libraries and sets all required variables
   # note that it's Qt4, not QT4 or qt4
   FIND_PACKAGE( Qt4 REQUIRED )
   # add some useful macros and variables
   # (QT_USE_FILE is a variable defined by FIND_PACKAGE( Qt4 ) that 
   # contains a path to CMake script)
   INCLUDE( ${QT_USE_FILE} )

# Set some Win32 Specific Settings
IF(WIN32)
 SET(GUI_TYPE WIN32)
ENDIF(WIN32)


add_executable (MyProgram ${GUI_TYPE}  ${SRCS})
TARGET_LINK_LIBRARIES(MyProgram ${QT_LIBRARIES})

Cheers
___________________________________________________________
Mike Jackson                      www.bluequartz.net
Principal Software Engineer       mike.jackson at bluequartz.net 
BlueQuartz Software               Dayton, Ohio

On Apr 27, 2011, at 9:10 AM, Cyrille Faucheux wrote:

> 
> 
> But it was a long time ago, and I was working with GTK...
> 
> Take a look at that: http://stackoverflow.com/questions/2139637/hide-console-of-windows-application
> 
> Good luck
> Cyrille
> 
> Le 27/04/2011 14:46, G G a écrit :
>> When I add WIN32, as you wrote
>> 
>> ADD_EXECUTABLE( Application WIN32 ${SRCS} ${UI_SRCS} ${RCC_SRCS})
>> 
>> then when I compile solution I get
>> 
>> Error    1    error LNK2019: unresolved external symbol _WinMain at 16 referenced in function ___tmainCRTStartup    MSVCRT.lib    Application
>> Error    2    fatal error LNK1120: 1 unresolved externals    C:\DP-ITK-APPS\src\my_test\bin\Release\Application.exe    Application
>> 
>> I have set window subsystem acording this
>> http://bobobobo.wordpress.com/2008/01/29/error-lnk2019-error1error-lnk2019-unresolved-external-symbol-_main-referenced-in-function-___tmaincrtstartupmsvcrtdlib/
>> 
>> (I think, that new solution is hasnt to be created?)
>> 
>> 
>> 
>> 2011/4/27 G G <greenlander1986 at gmail.com>
>> Thank you, I tried it ;)
>> 
>> 
>> 2011/4/27 Michael Jackson <mike.jackson at bluequartz.net>
>> In your add_executable call in your cmakelists.txt file you need to to
>> set the GUI type to win32. Look at the documentation for cmake to get
>> an idea of what you should write.
>> 
>> Mike Jackson
>> Www.bluequartz.net
>> 
>> On Wednesday, April 27, 2011, G G <greenlander1986 at gmail.com> wrote:
>> > I have tried it, but I ran console window again :(
>> >
>> > 2011/4/27 G G <greenlander1986 at gmail.com>
>> >
>> > 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
>> >
>> >
>> >
>> >
>> 
>> --
>> _________________________________________________________
>> Mike Jackson                  mike.jackson at bluequartz.net
>> BlueQuartz Software                    www.bluequartz.net
>> Principal Software Engineer                  Dayton, Ohio
>> 
>> 
>> 
>> _______________________________________________
>> 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




More information about the vtkusers mailing list