如下面這個
examples\tutorial\t1
#include <QApplication>
#include <QPushButton>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QPushButton hello("Hello world!");
hello.resize(100, 30);
hello.show();
return app.exec();
}
2007-7-20:
我用的是qt-win-eval-4.3.0-vs2003.exe,30天試用期。
開始 -> 所有程序 -> Qt by Trolltech v4.3.0 (Eval. VS2003) -> Qt 4.3.0 Command Prompt
用這個命令行的好處是它會配置環境:
Setting up a Qt environment...
-- QTDIR set to D:\Qt\4.3.0
-- Added D:\Qt\4.3.0\bin to PATH
-- QMAKESPEC set to win32-msvc.net
Setting environment for using Microsoft Visual Studio .NET 2003 tools.
(If you have another version of Visual Studio or Visual C++ installed and wish
to use its tools from the command line, run vcvars32.bat for that version.)
D:\Qt\4.3.0>
執行以下操作:
D:\Qt\4.3.0>cd examples\tutorial\t1
D:\Qt\4.3.0\examples\tutorial\t1>qmake
會生成3個makefile:
Makefile
Makefile.Debug
Makefile.Release
俄
這些makefile 是根據t1.pro生成的,內容如下:
ps : 用慣了vs的集成環境,自己寫個*.pro是不是會很痛苦?
TEMPLATE = app
CONFIG += qt warn_on
HEADERS =
SOURCES = main.cpp
TARGET = t1
QTDIR_build:REQUIRES="contains(QT_CONFIG, small-config)"
# install
target.path = $$[QT_INSTALL_EXAMPLES]/tutorial/t1
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS t1.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/tutorial/t1
INSTALLS += target sources
再執行以下操作,操作及效果如下:
D:\Qt\4.3.0\examples\tutorial\t1>nmake
Microsoft (R) 程序維護實用工具 7.10.3077 版
版權所有 (C) Microsoft Corporation。保留所有權利。
nmake -f Makefile.Debug all
Microsoft (R) 程序維護實用工具 7.10.3077 版
版權所有 (C) Microsoft Corporation。保留所有權利。
nmake -f Makefile.Release all
Microsoft (R) 程序維護實用工具 7.10.3077 版
版權所有 (C) Microsoft Corporation。保留所有權利。
呵呵,可以了
生成 *.pro
D:\Qt\4.3.0\practise_lai\HelloWorld>qmake -project
下面是生成的 HelloWorld.pro 文件:
######################################################################
# Automatically generated by qmake (2.01a) ??? ?? 21 02:55:38 2007
######################################################################

TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .

# Input
SOURCES += HelloWorld.cpp

生成Makefile
當你已經創建好你的項目文件,生成Makefile就很容易了,你所要做的就是先到你所生成的項目文件那里然后輸入:
Makefile可以像這樣由“.pro”文件生成:
qmake -o Makefile hello.pro
對于Visual Studio的用戶,qmake也可以生成“.dsp”文件,例如:
qmake -t vcapp -o hello.dsp hello.pro
Q: 為什么我這樣生成的*.dsp文件是損壞的?在vs2003里加不到解決方案里面
posted on 2007-07-20 05:01
七星重劍 閱讀(1422)
評論(4) 編輯 收藏 引用 所屬分類:
PL--c/c++ 、
C++ lib -- Qt