【VC++开源代码栏目提醒】:网学会员鉴于大家对VC++开源代码十分关注,论文会员在此为大家搜集整理了“2005 下如何编译安装并开发 QT 4 7 2 应 - 互联网”一文,供大家参考学习
2005 下如何编译安装并开发 QT 4 7 2 应
VC 2005下如何编译安装并开发QT 4.7.2应用程序2011-03-03 0846Qt是一个跨平台的C图形用户界面库由挪威TrollTech公司出品Qt支持所有的UNIX系统包括Linux系统还支持WinNT/Win2k、Windows 95/98平台。
本文将使用简单的几个步骤说明在
VC 2005下如何编译安装并开发QT应用程序 一、下载及安装 1.从官方网站下载QT最新版本源
代码假定解压到DQt.7.2目录 2.从
VC 2005的安装路径找到vsvars32.bat例如在EProgram FilesMicrosoft Visual Studio 8Common7Tools运行cmd 注如果是全编译最好准备25G以上空间4.7.2自带的examples编译完就有20.5G CE EEProgram FilesMicrosoft Visual Studio 8Common7Tools EProgram FilesMicrosoft Visual Studio 8Common7Tools vsvars32.bat EProgram FilesMicrosoft Visual Studio 8Common7Tools D Dcd DQt.7.2 DQt.4.0 configure-debug-and-release-static或用这个动态可以省时和省空间configure-shared-debug-and-release-no-exceptions-no-webki DQt.4.0 nmake configure-debug-and-release-static参数的意义是告诉QT同时编译为Debug和Release两个版本的静态链接库不指定参数则编译为Debug版本的动态链接库。
configure大约需要十几分钟nmake需要N小时删除examples可以大量节省时间视你的电脑性能而定。
3.将Qt路径添加到
VC编译环境中工具-选项-项目和解决方案-
VC目录在包含文件一栏添加DQt.7.2includeQtGuiDQt.7.2includeQtCoreDQt.7.2include在库文件一栏添加DQt.7.2lib将QT安装路径添加到Path系统环境变量中例如DQt.7.2bin 二、交叉编译 1.启动
VC创建一个Hello Qt工程将工程设置改为使用多字节字符集因为Qt Application的入口函数不是Unicode的 2.启动Qt Designer新建窗体-选择对话框窗体第一个选择项在新建的对话框上面放一个Label控件将其Title修改为Hello Qt将该窗体保存到刚才用
VC建立的Hello Qt工程目录文件名为Hello.ui 3.将Hello.ui作为源文件添加到Hello Qt工程中在Hello.ui上点击右键-属性在属性对话框中选择自定义生成步骤-常规在命令行一栏输入uic.exe Hello.ui-o HelloUi.h说明一栏输入正在编译Hello.ui在输出一栏输入HelloUi.h在附加依赖项一栏输入uic.exeHello.ui点击确定 注意也可以不使用手工添加方式添加编译ui文件直接使用qmake编译成
VC工程但这样会破坏原来的工程设置因为当ui文件修改或添加新的ui后需要重新qmake重新生成
VC工程因此这里采用了手工添加并设置编译脚本的方式qmake的用法如下 DHello Qt qmake-project-t vcapp-o HelloQt.pro DHello Qt qmake 不需要指定ui文件qmake会将当前目录所有的ui文件以及C文件创建一个
VC工程。
另外QT 4.4是对
VC各个版本都兼容的
VC6、
VC2003、
VC2005、
VC2008编译安装步骤都是一致的。
4.在Hello.ui上点击右键-编译将在当前工程目录生成HelloUi.h文件 5.打开Hello Qt.cpp在main函数添加启动
代码完整
代码如下 //Hello Qt.cpp定义控制台应用程序的入口点。
includestdafx.h includeHelloUi.h//ui文件编译生成的C文件 include QApplication int _tmainint argc_TCHARargv QApplication appargcargv QDialogdlgnew QDialog//Qt窗口对象会自动回收所有的子窗口对象这里的dlg将被作为最外层窗口将由QApplication进行回收因此Qt窗口只能在堆分配对象且不必使用delete。
UiDialog ui//Dialog为ui文件编译生成的C类参见HelloUi.h ui.setupUidlg dlg-show return app.exec 在工程设置附加依赖项中添加QtCore.lib QtGui.lib编译工程运行即可出现Hello Qt程序。
Windows程序里面的消息机制在MAC平台则是苹果事件各平台的驱动方式各异Qt则将这些不一致的平台机制统一起来形成了信号和槽机制来处理各种系统事件以实现跨平台的目的因此Qt程序几乎不经过任何修改便可以在其它平台编译通过。
附 下面是从网上搜索到的configure的具体参数供大家编译参考 配置参数选项 前面是号的表示默认参数.号表示该功能要求被评估评估成功后才能被接受. -release.调试关闭.没有调试库自己的项目只能发布不能调试没有调试库的缘故如果你硬要编译debug版本的话会提示找不到xxxxxd.dll -debug.只有调试库没有释放库也就是说以后自己的项目只能调试如果你硬要编译debug版本的话会提示找不到xxxxx.dll -debug-and-release.编译后包含两种库。
最好编译两种库 -opensource.编译
开源版. -commercial.编译商业版.这两个参数一般不需指定configure开始需要你选择版本。
-developer-build.编译开发者选项。
-shared.动态编译. -static.静态链接库.貌似有插件不能用静态编译。
-no-fast.configure生成所有项目makefiles文件并编译 -fast.只生成库目录及子目录下的项目的makefiles文件. -no-exceptions.关闭异常支持 -exceptions.开启异常支持. -no-accessibility.关闭对windows active控件支持. -accessibility.对windows active控件支持. -no-stl.无c标准库支持/hi.baidu.com/lewutian -stl.有标准库支持 尖括号在blogger出问题了。
-no-sql-.Disable SQL entirelyby default none are turned on. -qt-sql-.Enable aSQL in the Qt Library. -plugin-sql-Enable SQL as aplugin to be linked to at runtime. Available values for mysql psql oci odbc tds db2 sqlite sqlite2 ibase drivers marked with ahave been detected as available on this system -system-sqlite.Use sqlite from the operating system. -no-qt3support.不提供对qt3函数支持 -no-opengl.不提供OpenGL函数支持 -platform.The operating system and compiler you are building on. defaultQMAKESPEC -xplatform.The operating system and compiler you are cross compiling to. See the README file for alist of supported operating sy stems and compilers. -qtnamespace Wraps all Qt library code innamespace name. -D.Add an explicit define to the preprocessor. -I.Add an explicit include path. -L.Add an explicit library path. -l.Add an explicit library nameresiding in alibrarypath. -graphicssystem Specify which graphicssystem should be used. Available values for raster-Software rasterizer opengl-Using OpenGL accellerationexperimental -help-h-.Display this information. 第三方库 -qt-zlib.使用zlib绑定到qt. -system-zlib.使用操作系统的zlib 见-no-gif.不编译gif文件读取支持插件 -qt-gif.编译gif文件读取支持插件 参见src/plugins/imageformats/gif/qgifhandler.h -no-libpng.不编译PNG支持插件. -qt-libpng.编译PNG支持插件. -system-libpng.使用系统libpng库 见-no-libmng.不编译MNG支持插件. -qt-libmng.编译MNG支持插件. -system-libmng.使用系统的mng库 参见-no-libtiff.不编译tiff支持插件. -qt-libtiff.编译tiff支持插件. -system-libtiff.使用系统的libtiff库 见-no-libjpeg.不编译jpeg支持插件库 -qt-libjpeg.编译jpeg支持插件库 -system-libjpeg.使用系统的jpeg支持库 见以下参数仅对qt for windows有效 -no-dsp.不生成
VC.dsp文档. -dsp.生成
VC.dsp文档需要有平台标识符win32-msvc.注意qt4开始就不支持
vc6.0了所以这两个参数无效。
-no-vcproj.不生成
VC.vcproj文档 -vcproj.生成
VC.vcproj文档需要平台标识符win32-msvc.net.也就是vs2003以上的编译环境 -no-incredibuild-xge Do not add IncrediBuild XGE distribution commands to custom build steps. -incredibuild-xge.Add IncrediBuild XGE distribution commands to custom build steps.This will distribute MOC and UIC stepsand other custom buildsteps which are added to the INCREDIBUILD_XGE variable. The IncrediBuild distribution commands are only added to Visual Studio projects -no-plugin-manifests插件不嵌入manifests. -plugin-manifests.插件嵌入manifests. -no-qmake.不编译qmake -qmake.编译qmake.不建议不编译qmake -dont-process.不生成makefiles和project文档.比-no-fast参数优先级更高 -process.生成makefiles和project文档. -no-rtti.不编译运行时类型信息。
-rtti.编译运行时类型信息。
//下面是对指令的支持不解释了 -no-mmx.Do not compile with use of MMX instructions -mmx.Compile with use of MMX instructions -no-3dnow.Do not compile with use of 3DNOW instructions -3dnow.Compile with use of 3DNOW instructions -no-sse.Do not compile with use of SSE instructions -sse.Compile with use of SSE instructions -no-sse2.Do not compile with use of SSE2 instructions -sse2.Compile with use of SSE2 instructions -direct3d.将Direct3D支持编译进来。
检测不到direct3d sdk就不支持 -no-openssl.Do not compile in OpenSSL support -openssl.Compile in run-time OpenSSL support -openssl-linked.Compile in linked OpenSSL support -no-dbus.Do not compile in D-Bus support -dbus.Compile in D-Bus support and load libdbus-1 dynamically -dbus-linked.Compile in D-Bus support and link to libdbus-1 -no-phonon.不将Phonon模块编译进来 -phonon.将Phonon模块编译进来若使用的规范的c编译器则会自动编译Phonon模块 -no-phonon-backend.Do not compile the platform-specific Phonon backend-plu gin -phonon-backend.Compile in the platform-specific Phonon backend-plugin -no-webkit.不将webkit模块编译进来编译webkit非常耗时间。
-webkit.将webkit模块编译进来若使用的规范的c编译器则会自动编译WebKit模块 -no-scripttools.Do not build the QtScriptTools module. -scripttools.Build the QtScriptTools module. -arch.外观样式. 有以下几种 windows windowsce boundschecker generic -no-style-尖括号里包含上面的样式。
上一篇:
Q登录加密算
下一篇:
电话销售英文简历范文