Part I
Environment:
1) vs2010
Directory: e: \ Program Files (x86) \ Microsoft Visual Studio 10.0
2. qtplug-in for vs(qt-vs-addin-1.1.11-opensource.exe)
3) Qt for vs2010 (qt-win-opensource-4.8.4-vs2010.exe)
Directory: e: \ CPP \ QT \ 4.8.4
Part II
1. Open the Visual Studio command prompt (2010) in vs2010, and then you can use nmake.
Let's take a look at the path. There are a lot more directories in.
2. Set the QT environment variable so that qmake can be used.
Set Path = % PATH %; E: \ CPP \ QT \ 4.8.4 \ bin"
E: \ Program Files (x86) \ Microsoft Visual Studio 10.0 \ Vc> set Path = % PATH %; E: \ CPP \ QT
\ 4.8.4 \ bin
View the path again. E: \ CPP \ QT \ 4.8.4 \ bin is displayed.
3. Switch to the project directory
E: \ Program Files (x86) \ Microsoft Visual Studio 10.0 \ Vc> Cd E: \ projects \ QT \ demo
4. Use qmake to generate the pro file.
E: \ projects \ QT \ demo> qmake-Project
For example, qmake-Project QT + = Network
Qt + = Network: adds the network module, which is equivalent to QT modules in QT project setting in QT plug-in of.
You can find one more option in the generated pro file.
Use qmake-help (-Help, Linux style) to view help information
5. Generate the MAKEFILE file
E: \ projects \ QT \ demo> qmake demo. Pro
RCC: Warning: no resources in 'demo. qrc '.
RCC: Warning: no resources in 'demo. qrc '.
6. compile the project
E: \ projects \ QT \ demo> nmake debug release
Nmake generates debug by default
..............
After compilation information or warning information (the MOC _ *. cpp file can be generated during the meta object compilation process)
Finally, you can find the execution file in the debug and release directories.
Nmake /? (/? Windows style) nmake help information
7. Run
E: \ projects \ QT \ demo> CD release
E: \ projects \ QT \ demo \ release> demo.exe
Oh, so Prefect!
Part III
After the QT version is updated on vs2010, the old version of the project cannot be compiled.
During Compilation:
The following error occured:
There's no QT version assigned to this project for platform win32. please use the 'Change QT version' feature and choose a valid QT version for this platform.
After all the settings, the version cannot be found. manually modify the project configuration file (only the XML file)
1. Modify the vcxproj File
Open demo. vcxproj in the text editor and find the QT version number (my version is 4.8.4)
?
12345 |
< ProjectExtensions > < VisualStudio > < UserProperties
UicDir = ".\GeneratedFiles"
MocDir = ".\GeneratedFiles\$(ConfigurationName)"
MocOptions = ""
RccDir = ".\GeneratedFiles"
lupdateOnBuild = "0"
lupdateOptions = ""
lreleaseOptions = ""
QtVersion_x0020_Win32 = "4.8.4"
/> </ VisualStudio > </ ProjectExtensions > |
Qtversion_x0020_win32 = "4.8.4 ″
2. Modify the User File
Open demo. user in a text editor
?
1 |
< QTDIR >E:\cpp\Qt\4.8.4</ QTDIR > |
Note:
Qmake compilation was initially referred to at: "C ++ GUI qt4 programming" p3