I have tried using MinGW, Qt, MSYS to write Windows Application,but I think most of us prefer to use Visual Studio to do coding job and using Qt under Windows is a trend.

1) build the environment

First we install Qt, Visual Studio and add Qt path to system PATH environment:

C:\Qt\4.7.1\bin

and we also add VC++ path into system PATH:

C:\Program Files\Microsoft Visual Studio 9.0\VC\bin

2) Create Qt project for Hellow World

Put Hello World into a cpp file:

#include #include

int main(int argc, char *argv[]) { QApplication app(argc, argv);

QPushButton hello("Hello world!");
hello.resize(100, 30);

hello.show();
return app.exec();

}

Then open Qt Commandline Prompt , get into this folder and execute following commands:

qmake -project qmake

According to the platform depended makefile file, we can use VC to compile the project:

nmake

3) using VC integrated development environment

If you want to use VC++ for code editing, then you just need to change the commands in point 2 to following:

qmake -project qmake -tp vc

Then you will get a VC++ project and it will include all source files under current folder.

4) FAQ

For beginners, if you use Windows commanline to run above commands, then you will get an error when using nmake:

NMAKE : fatal error U1077: ‘“C:\Program Files\Microsoft Visual Studio 9.0\VC\bin \nmake.exe”’ : return code ‘0x2’ Stop.

The solution is very simple, just use Qt Commandline Prompt for all commands.