Talk:Qt4 with Visual Studio
From qtnode
Can someone please help with this article:
- can you reproduce my steps?
- can you tell me on this discussion page your success story (with details like compiler/platform)
- can someone to the section about making Visual Studio projects (I haven't done this)
- can someone add a section about managing .pro's and VS projects, making changes, etc...
Thanks, Nuge
In reply to Qt4_with_Visual_Studio#Maintaining_Visual_Studio_Projects, the problem is with the .pro and .vcproj file getting out of sync. You can add files to the .vcproj easily enough. But say you had only a HEADERS and SOURCES section in your .pro file when you ran qmake to make the .vcproj file. You start adding more .cpp and .h files to the .vcproj file, but now you'd like to add a .ui file as well. You'd have to update the .pro file with the same files as the .vcproj file or create the filters and build rules through Visual Studio. So in this example, unless you had a FORMS variable in your .pro file at the time of running qmake, the .vcproj file won't have any rules for compiling those with uic.
- Does this mean we should suggest using the .pro as the master file? Do not add files to your vcproj unless they are simply not qt-dependent (i.e. they are not .ui or .qrc and they do not have Q_OBJECT). Unless you make changes to your project settings in the IDE, I don't think it's a big deal to use your .pro as the master project file and always recreate vcproj. I don't know how other people would think about this though.
-Nuge
- I don't think most people would want to use Visual Studio this way. Maybe one way is to make a template .pro file for each type (app, plugin, and so on) including everything in it (HEADERS, SOURCES, FORMS, RESOURCES, ...). Then you convert those into template .vcproj files. Adding filters for files is easy enough in Visual Studio, but I'm not sure how to add their build rules (e.g., for running uic or rcc). The .vcproj file is just an XML file, but the filter section seems to rely on a file existing so you can specify the build rules for it. At least I don't know how to add a rule without their being a file of that type present, because of the nested structure of the .vcproj file. Still, this doesn't solve converting them back into .pro files for portability.
-Blockd
- I don't think most people would want to use Visual Studio this way. Maybe one way is to make a template .pro file for each type (app, plugin, and so on) including everything in it (HEADERS, SOURCES, FORMS, RESOURCES, ...). Then you convert those into template .vcproj files. Adding filters for files is easy enough in Visual Studio, but I'm not sure how to add their build rules (e.g., for running uic or rcc). The .vcproj file is just an XML file, but the filter section seems to rely on a file existing so you can specify the build rules for it. At least I don't know how to add a rule without their being a file of that type present, because of the nested structure of the .vcproj file. Still, this doesn't solve converting them back into .pro files for portability.
- OK, then. Want to edit that section accordingly? I'm not sure what to suggest to users.
-Nuge
- OK, then. Want to edit that section accordingly? I'm not sure what to suggest to users.
Is it possible to change the default template from app to vcapp. Would it be as simple as changing the appropriate qmake.conf. Would you need to re-compile qmake?
-Nuge
- It is possible with a recompiled qmake, but I don't think this is a good idea because this would bring inconsistency to the commercial version.
Hi, following the instructions I found here I could build Qt using Visual C++ 2005 Express Edition (VC8). I could do it two times in two different machines. The main problems I found are related about the enviroment variables from VC2005 which has to be set prior to make anything. I found a trick to add a "VC2005 Command Prompt here" to the Windows Explorer context for any folder. It allows to open a command prompt window with vcvarsall.bat executed so you don't have to add a path to this program and execute it everytime you want to build a Qt project. Another problem: it must be remarked that the enviroment variable QMAKESPEC needs to be created. It is not clear at all. I discover this after some trials. Maybe there's another easier way to set it... All things seems to be right but not so. I used qmake -project -t vcapp -o myProject.pro to generate a pro file with hello.cpp as a source file. I got myProject.pro file. Then used qmake and get the myProject.vcproj file and the "debug" and "release" folders. But when I open the .vcproj file (double click) with VC2005 IDE and look at project properties page, there is nothing like the options mentioned in the instructions that follows afterwards. I mean NMake, clean, rebuild etc. I downloaded the example zip file, look at the .pro file and is quite different from mine .pro:
myProj.pro:
\######################################################################
\# Automatically generated by qmake (2.01a) Tue Jan 9 22:32:00 2007
\######################################################################
TEMPLATE = vcapp
TARGET = myProj
DEPENDPATH += .
INCLUDEPATH += .
src.pro (from the example zip)
\# Input SOURCES += hello.cpp
TEMPALTE += app
CONFIG += qt warn_on
SOURCES += main.cpp MyWidget.cpp
HEADER = MyWidget.h
TARGET = example
Anyway I found in the same zip file a src.vcproj for VC2003 that I could convert to VC2005. This one has the options you mentioned and the project properties page looks totally different from my project. I am astonished, but I must confess... I am just beginning with this. Anyway I think I reach so far I can not give up now. I was following Qt tutorial making some simple applications and Qt seems a great tool!!. I will deeply appreciate if you can help me in this point. I think also VC2005 EE is a good free alternative for making apps in C++ (I was making large projects with excellent results) and the cool graphics from Qt will give them the impresive look that I was looking for. Thanks in advance. Mario