Installing Qt for Windows

Qt for Windows has some requirements that are given in more detail in the Qt for Windows Requirements 文档。

If you have obtained a binary package for this platform, consult the installation instructions provided instead of the ones in this document.

Open Source Versions of Qt is not officially supported for use with any version of Visual Studio. Integration with Visual Studio is available as part of the Qt Commercial Edition.

Step 1: Install the License File (commercial editions only)

If you have the commercial edition of Qt, copy the license file from your account on dist.trolltech.com into your home directory (this may be known as the userprofile environment variable) and rename it to .qt-license . This renaming process must be done using a command prompt 在 Windows, not with Windows Explorer. For example on Windows 2000, %USERPROFILE% should be something like C:\Documents and Settings\username

For the open source version you do not need a license file.

步骤 2:解包存档

把文件解压到要安装 Qt 的目录;如 C:\Qt\%VERSION% .

注意: 安装路径不得包含任何空格或 Windows 特定文件系统字符。

Step 3: Set the Environment variables

In order to build and use Qt, the PATH environment variable needs to be extended:

PATH               - to locate qmake, moc and other Qt tools
					

This is done by adding c:\Qt\%VERSION%\bin PATH 变量。

For newer versions of Windows, PATH can be extended through the Control Panel|System|Advanced|Environment variables 菜单。

You may also need to ensure that the locations of your compiler and other build tools are listed in the PATH variable. This will depend on your choice of software development environment.

注意: If you don't use the configured shells, which is available in the application menu, in the Qt 的开源版本 , configure requires that sh.exe is not in the path or that it is run from msys . This also goes for mingw32-make.

步骤 4:构建 Qt 库

To configure the Qt library for your machine, type the following command in a Visual Studio command prompt:

C:
cd /D C:\Qt\%VERSION%
configure
					

类型 configure -help to get a list of all available options. The Configuration Options for Qt page gives a brief overview of these.

If you have multiple compilers installed, and want to build the Qt library using a specific compiler, you must specify a qmake specification. This is done by pasing -platform <spec> to configure; for example:

configure -platform win32-msvc
					

In some cases you need to set up the compilation environment before running configure in order to use the right compiler. For instance, you need to do this if you have Visual Studio 2005 installed and want to compile Qt using the x64 compiler because the 32-bit and 64-bit compiler both use the same qmake specification file. This is usually done by selecting Microsoft Visual Studio 2005|Visual Studio Tools|<Command Prompt> Start 菜单。

The actual commands needed to build Qt depends on your development system. For Microsoft Visual Studio to create the library and compile all the demos, examples, tools and tutorials type:

nmake
					

注意: 若以后需要在相同位置重新配置和重构 Qt,确保移除所有先前配置痕迹,通过进入构建目录并键入 nmake distclean 先于运行 configure 再次。

That's all. Qt is now installed.

Qt 演示和范例

If you are new to Qt, we suggest that you take a look at the demos and examples to see Qt in action. Run the Qt Examples and Demos either by typing qtdemo on the command line or through the desktop's Start menu.

You might also want to try the following links:

We hope you will enjoy using Qt. Good luck!