C++ GUIProgramming with Qt3的知识介绍

C++ GUIProgramming with Qt3的知识介绍

It's time to test the program on your machine.First,you will need to install Qt 3.2(or later Qt 3 release), a process that is explained in Appendix A. From now on,we will assume that you have a correctly installed copy of Qt 3.2 and that Qt's bin directory is in your PATH environment variable.(On windows,this is done automatically by the Qt installation program,so you don't need to worry about it.)
在你的机子上运行该程序的时候到了。首先,你需要安装Qt3.2(或更高版本),安装过程将在附录中描述。现在,假设你已经正确安装了Qt3.2并且把Qt 的bin目录加到了你的PATH这个环境变量中(在windows系统中安装程序将自动完成这部分工作,不需要你操心了)。

You will also need the Hello program's source code in a file called hello.cpp in a directory called hello.You can type in hello.cpp yourself,or copy it from the cd provided with this book, where it is available as /examples/chap01/hello/hello.cpp
另外你还要有一个保存在hello目录下的hello.cpp文件(译:其实也不是必须的,只是Qt的项目名称是和源文件所处目录同名)。你可以自己输入hello.cpp文件,或者在本书提供的光盘中找到,他的路径是/examples/chap01/hello/hello.cpp.
From a command prompt,change directory to hello,then type
qmake -project
to create a platform-independent project file (hello.pro),then type
qmake hello.pro
在一个命令行窗口中,进入到hello目录中,然后键入
qmake -project
来产生一个与平台无关的项目文件(hello.pro),接着键入
qmake hello.pro

to create a platform-specific makefile from the project file.Run make to build the program, and run the program by typeing hello on windows, ./hello on Unix, and open hello.app on Mac OS X. If you using Microsoft Visual c++ you will need to run nmake instead of make. Alternatively,you can create a Visual Studio project file from hello.pro by typeing
qmake -tp vc hello.pro
and then build the program in Visual Studio.
来产生一个和平台相关的makefile文件。运行make来编译连接该程序。下面就可以运行该程序了。在windows平台下键入hello,如果是Unix 就敲./hello,Mac OX x系统就敲hello.app。如果你使用的是微软的Visual C++你可以使用nmake来代替make或者通过键入qmake -tp vc hello.pro 产生一个Visual Studio的项目文件那样的话就可以在Visual Studio中编译连接应用程序了。
C++ GUIProgramming with Qt3的知识介绍
Now let's have some fun:we will brighten up the label by using some simple HTML-Style formatting.This can be done by replacing the line
QLabel *label = new QLabel("Hello Qt!",0);
with
QLabel *label = new QLabel("<h2><i>Hello</i><font color=red>Qt!</font><h2>",0);
and rebuildinig the application.
现在我可以做一些有趣的事情:我们可以用一些简单的HTML-Style样式使我们的label变得炫一些。我们只需要把
QLabel *label = new QLabel("Hello Qt!",0);替换成
QLabel *label = new QLabel("<h2><i>Hello</i><font color=red>Qt!</font><h2>",0);然后重新编译连接一下程序就可以了。