• 10835阅读
  • 7回复

qt4.3.2 安装 (vs2005+winxp)by navyblue_bobo [复制链接]

上一主题 下一主题
离线navyblue
 
只看楼主 倒序阅读 楼主  发表于: 2007-11-24
— 本帖被 XChinux 设置为精华(2008-06-13) —
1. qt4.3.2的安装:
请直接使用src包,不要使用mingw的包;解开源码包,啥都不用改,用vs2005的命令窗口执行configure.exe,然后里面就自动找到了msvc2005作为编译器(在显示内容的开始几行),然后configure很久,完毕后,nmake,大约1小时,编译完成,再执行nmake confclean,清理中间文件。

最重要的是使用
Visual Studio 2005 命令提示开启。
这个会自动设定很多VC2005的系统变量。
这样,编译的时候,就不会提示找不到相关文件。

最后才是改qtvar.bat
@echo off
rem
rem This file is generated
rem

echo Setting up a Qt environment...
echo -- QTDIR set to C:\Qt\4.3.2
echo -- Added D:\Qt\4.3.2\bin to PATH
echo -- QMAKESPEC set to win32-msvc2005

set QTDIR=C:\Qt\4.3.2
set PATH=C:\Qt\4.3.2\bin;%PATH%
set QMAKESPEC=win32-msvc2005

if not "%1"=="vsvars" goto END
call "C:\Program Files\Microsoft Visual Studio 8\\Common7\Tools\vsvars32.bat"
:END

if not "%1"=="vsstart" goto ENDSTARTVS
call "C:\Program Files\Microsoft Visual Studio 8\\Common7\Tools\vsvars32.bat"
devenv /useenv
:ENDSTARTVS

上面这个文件中的内容可以手动设置,
即设置变量
QTDIR=c:\qt\4.3.2
QMAKESPEC=win32-msvc2005
添加PATH=C:\QT\4.3.2\bin

完成上述工作后,qt环境设置好了。

2:在vs2005中使用qt4.3.2

首先在vs2005中加入头文件,库文件的查找路径:
tools->options->projects and solutions->vc++ directories->include files加入c:\qt\4.3.2\include
在library中加入c:\qt\4.3.2\lib

完成上述工作后:我们着手建立一个空的makefile project
new->project ->general->makefile project
进入工程属性页 property pages

First you create a new Makefile Project in a empty solution. Then go to the project Property Pages (right click project-〉Properties). Make sure that Debug is the current Configuration and choose "NMake" in the left menu. Then open the Window for "Build command Line" by clicking the "..." Button. Here you enter:

%QTDIR%\bin\qmake
nmake debug
In "Rebuild Command Line" you enter:

%QTDIR%\bin\qmake
nmake debug-clean
nmake debug
And in "Clean Command Line":

%QTDIR%\bin\qmake
nmake debug-clean
Now the last change, in "Output" enter:

debug\[you app Name].exe
Now do the same thing for release Configuration, but substitute "debug" with "release" ( also in Output Path!)

Now confirm this dialog with OK and create a new File. To do so right click your project and choose Add->Add new Files. Here choose "Text File (.txt)" and as name enter "src.pro", or something similar. In this file enter:

TEMPLATE = app
CONFIG  += qt [do you config here, mine would be: "qt warn_on"]
QT  += [do you qt-config here]
SOURCES  = main.cpp
HEADERS  =
TARGET  = [your App Name]

win32:debug:CONFIG += console [->if you want to receive qDebug() messages on Windows...]
Save this file and add another file to your project: main.cpp, do it as you did it with the pro File, but choose "C++ File (.cpp)" as file type.

If you want to add another source file to your project, just add it with the add menu, and don't forget to add the files to the right section in your pro-File. This pro file can be used like any normal pro-File, without any problems.

按以上步骤操作后
随便做一个测试:
#include <QApplication>
#include <QPushButton>
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QPushButton *button = new QPushButton("Quit");
    QObject::connect(button, SIGNAL(clicked()),
                      &app, SLOT(quit()));
    button->show();
    return app.exec();
}

ok!!! navyblue_bobo 2007.11.18
离线simonetta
只看该作者 1楼 发表于: 2007-11-25
嵌入了QtDesigner了?
可以直接debug么?
我的blog
http://blog.csdn.net/solotek97/
离线yao_zhuang

只看该作者 2楼 发表于: 2008-06-12
好文,顶了
离线lihanwuhan
只看该作者 3楼 发表于: 2008-07-26
我按照楼主的方法安装很顺利,谢谢:)
离线猪蛋
只看该作者 4楼 发表于: 2008-07-28
呵呵,我装的 也是 QT4.3.2,不过 我看的是一个叫王长发的blog,楼主应该也是看的那个blog吧
离线wotacid
只看该作者 5楼 发表于: 2008-08-31
我的qt-win-opensource-4.4.1-mingw
安装在那里合适,C盘2





qt-win-opensource-4.4.1-mingw
安装在那里合适
C盘2G解压一下子就吃光了,无法安装进去
离线wotacid
只看该作者 6楼 发表于: 2008-09-01
vs2005是2G大的东西吗?非要不可的是吗
离线kevineml

只看该作者 7楼 发表于: 2008-12-16
Make sure that Debug is the current Configuration and choose "NMake" in the left menu. Then open the Window for "Build command Line" by clicking the "..." Button.
VS2005里没有NMAKE这个选项啦 怎么办
快速回复
限100 字节
 
上一个 下一个