[vtkusers] VTK and QT Projects (QVTKWidget.h)
Alex Southern
mrapsouthern at gmail.com
Mon Aug 2 09:58:59 EDT 2010
I solved my problem.... almost,
basically despite having a working application in VS 2008, I decided to
use my source files to build a new one using cmake. For future reference
the file is below, although a word of warning.....
I included the WIN32 option (in ADD_EXECUTABLE) in order to stop the
console window appearing in addition to my gui. Upon compilation this
caused 2 linker errors, I stopped both of these by adding qtmain.lib to
the linker's additional dependencies. This solved the problem BUT I'm
sure that Cmake should be doing this for me, so the cmakelists file is
probably missing something.
Secondly, The project only runs in Release Mode !!, I did some digging
and this has something to do with QT dll conflicts. The output window
shows that it is loading both the release and debug versions of
Qtcore4.dll Qtgui4.dll (Qtcored4.dll Qtguid4.dll) as of yet I dont know
how stop this....
Any ideas?
Cmake file below
---------------------------------------
cmake_minimum_required(VERSION 2.8)
PROJECT(WaveModellerVTK)
FIND_PACKAGE(VTK)
INCLUDE(${VTK_USE_FILE}) # include UseVTK.cmake
FIND_PACKAGE(Qt4 REQUIRED)
INCLUDE(${QT_USE_FILE}) # include UseQt4.cmake
# support for out-of-source build
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
)
# Set your files and resources here
SET(WMSrcs main.cpp wavemodeller.cpp nodfile.cpp newproject.cpp)
SET(WMUI wavemodeller.ui newproject.ui)
SET(WMqrc wavemodellericons.qrc)
SET(WMHeaders wavemodeller.h nodFile.h newproject.h)
QT4_WRAP_UI(UISrcs ${WMUI})
QT4_ADD_RESOURCES(UIico ${WMqrc})
QT4_WRAP_CPP(MOCSrcs ${WMHeaders} )
SOURCE_GROUP("Resources" FILES
${WMUI}
)
SOURCE_GROUP("Generated" FILES
${UISrcs}
${MOCSrcs}
# ${RCS_SOURCES}
)
ADD_EXECUTABLE( WaveModellerVTK WIN32 ${WMSrcs} ${UIico} ${WMUI} ${MOCSrcs})
TARGET_LINK_LIBRARIES( WaveModellerVTK QVTK )
-------------------------------------------------------------
On 30.7.2010 23:08, Darshan Pai wrote:
> Hi Alex,
>
> you should probably include the QVTKWidget.h that is present in your
> bin folder rather than the source folder . The reason is that when you
> compile VTK with GUISupport it generates a moc file for the widget
> which is saved in the bin folder and will be needed for QT .
>
> Regards
> Darshan
>
> On Fri, Jul 30, 2010 at 12:19 PM, Alex Southern
> <mrapsouthern at gmail.com <mailto:mrapsouthern at gmail.com>> wrote:
>
> Hi,
>
> QT has been working fine up until I try to compile a gui with a
> vtkwidgetplugin in. However just in case it does matter, yes I
> beleive I did.
>
> In Project->Properties->C/C++->Additional Include Directories...
> ".\GeneratedFiles;"$(QTDIR)\include";".\GeneratedFiles\$(ConfigurationName)";"$(QTDIR)\include\qtmain";"$(QTDIR)\include\QtCore";"$(QTDIR)\include\QtGui";.\
>
> In Project->Properties->Linker->Additional Library Directories...
> "$(QTDIR)\lib"
>
> QTDIR has been set in the Environment Variables in My
> Computer->Properties->Advanced etc
>
> In Project->Properties->Linker->Additional Dependencies...
> qtmaind.lib QtCored4.lib QtGuid4.lib $(NOINHERIT)
>
> Although like I said the QT stuff works fine, If I remove the
> VTKwidget and try to compile the app it works perfectly.
>
> Cheers
> Alex
>
>
> On 30.7.2010 19:08, Bobby Ren wrote:
>> did you add the qt include directory into your additional
>> includes folders list under the project settings?
>>
>>
>> On Fri, Jul 30, 2010 at 11:59 AM, Alex Southern
>> <mrapsouthern at gmail.com <mailto:mrapsouthern at gmail.com>> wrote:
>>
>> Hi,
>>
>> (Not sure if I should post this here, but I think its a VTK
>> thing rather than QT)
>>
>> I'm sure this must be straight forward....
>>
>> I have been using QT to make a project in VS 2008 Pro,
>> Windows 7. All going well and then I want to add in the VTK
>> rendering window....
>>
>> Note: Yes, I installed QT first and waited a couple of hours
>> for it to build from source, then I installed VTK using cmake
>> with the required, VTK_USE_QT and VTK_GUISUPPORT, everything
>> eventually installed fine, cmake found the QT installation no
>> problem and then QT demos in VTK examples work fine.
>>
>> I copy the QVTKwidgetplugin.dll compiled by VTK over to the
>> C:/QT/4.6.3/plugins/designer folder. The vtk widget shows up
>> in the widgets box in QT designer when running through Visual
>> Studio and standalone.
>>
>> I then return to my QT project, open QT designer and add the
>> vtkwidget to my desired Tab. Save All. Exit QT Designer.
>>
>> Then I try to compile the project and I am presented with
>> "Cannot open include file: 'QVTKWidget.h': No such file or
>> directory".
>>
>> Note: I should add that my VTK installation is fine, my VTK
>> projects still compile an run no problem.
>>
>> The file exists in the VTK build folder C:\VTK\include\vtk-5.6
>>
>> So Im sure this has something to do with the fact the project
>> was never setup for VTK usage and I need to include the path
>> somehow. Although I have had no luck so far.
>>
>> Any suggestions please???
>>
>> Thanks
>> Alex
>>
>>
>> _______________________________________________
>> Powered by www.kitware.com <http://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 <http://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/20100802/939c25f6/attachment.htm>
More information about the vtkusers
mailing list