PDA

View Full Version : Qt with Visual Studio 2005



ustulation
14th August 2012, 11:49
hi, (this question may be more about Visual Studio but as i'm using it in conjunction with Qt and a few other posts contain questions on Visual Studio also, i took the liberty of posting this here)
i've the following in the custom build property of every header file that uses Q_OBJECT:

Command Line: $(THIRDPARTY_DIR)\qt\4.7.0\win32-vc10\bin\moc.exe $(InputFileName) -o moc\$(ConfigurationName)\moc_$(InputName).cpp
Description: ################### moc'ing $(InputFileName)
Outputs: moc\$(ConfigurationName)\moc_$(InputName).cpp
This generates the necessary moc files. I now want to ask visual studio to compile and link these too to my other source files. Presently i'm using
#include "moc\{Release OR Debug}\moc_Whatever.cpp" these statements in any of the files to force compilation and linking. Evidently i have to keep changing my #include according to debug or release build (i cannot discard $(ConfiguarationName) during moc file generation above for reasons). Plus i dont like the idea of writing this #include in the source files just for the purposes of compilation and linking.

Is there any build step in properties anywhere where i can mention what files will be generated in future and to compile and link them when they are available (VS2005)?

(i cannot use QtPlugin right now)

Lesiok
14th August 2012, 12:01
First don't include moc files to source files. Add them to project.
Second download and install Qt VS Addin (http://releases.qt-project.org/vsaddin/qt-vs-addin-1.1.11-opensource.exe) and create project from scratch.

ustulation
14th August 2012, 12:10
To add them to the project they must exist. This is what Visual Studio seems to check. I did the following: Project > add > new filter then Added a moc file from previously generated build. When i did clean (which deleted the moc file) and tried rebuilding the project it complained about the file not being present. how do i specify that it should look for it only after all the custom builds have been executed?

Lesiok
14th August 2012, 14:06
Qt VS Addin do this work for You. It is full automated.