本文讨论的是从Ubuntu的基础安装,也就是从CD安装盘默认安装后,开发Qt应用所需要的安装包。本文实验环境Ubuntu 9.04-desktop
下面就是需要作的几个步骤
1)
sudo apt-get install libqt4-dev安装完这个包后,你就可以写Qt程序了。libqt4-dev会自动把下面相关的一些qt4包安装上,例如:
libqt4-assistant libqt4-dbus libqt4-designer libqt4-help libqt4-network libqt4-opengl libqt4-opengl-dev libqt4-qt3support libqt4-script libqt4-scripttools libqt4-sql libqt4-sql-mysql libqt4-svg libqt4-test libqt4-webkit libqt4-xml libqt4-xmlpatterns libqtcore4 libqtgui4
sudo apt-get install g++ automake这俩个包并不属于qt包,但是编译Qt的c++编译器需要安装,在g++包里。Qt有自己的编译系统,automake并不是必须的,但有时候需要编译一些第三方的库,所以一般推荐安装上。
3)
sudo apt-get install qt4-dev-tools qt4-designer qt4-docqt4-dev-tools包含了一些开发用到辅助工具,如帮助系统工具assitant,翻译辅助工具linguist,d-bus查看器,Pixel Tool等。
qt4-designer则会安装GUI设计工具designer
qt4-doc qt4的帮助文件
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
下面是一些选装的安装包
4)
sudo apt-get install libqt4-opengl-devQt4 OpenGL 相关的开发库文件
5)
sudo apt-get install libqt4-sql-mysql libqt4-sql-odbc libqt4-sql-psql libqt4-sql-sqlite libqt4-sql-sqlite2开发数据库所要的一些插件驱动,可选取自己需要的包安装
5.1)
sudo install libiodbc2-dev libmysqlclient15-dev libsqlite3-dev对应步骤5)中的数据库所需的开发库文件
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
你可能还需要的内容 appendix
a1) sudo aptitude search qt4
这个命令会让你查到和qt4相关的其它内容,比如调试用的符号表文件,pyqt,perlqt等,搜索结果如下
p ffado-mixer-qt4 - FFADO D-Bus mixer applets (QT4)
p ibus-qt4 - New input method framework using dbus
p libavahi-qt4-1 - Avahi Qt 4 integration library
p libavahi-qt4-dev - Development headers for the Avahi Qt 4 inte
p libpoppler-qt4-3 - PDF rendering library (Qt 4 based shared li
p libpoppler-qt4-dev - PDF rendering library — development files
p libqt4-assistant - Qt 4 assistant module
p libqt4-core - transitional package for Qt 4 core non-GUI
p libqt4-dbg - Qt 4 library debugging symbols
p libqt4-dbus - Qt 4 D-Bus module
p libqt4-designer - Qt 4 designer module
p libqt4-dev - Qt 4 development files
p libqt4-dev-dbg - Qt 4 development files debugging symbols
p libqt4-gui - transitional package for Qt 4 GUI runtime l
p libqt4-help - Qt 4 help module
p libqt4-network - Qt 4 network module
p libqt4-opengl - Qt 4 OpenGL module
p libqt4-opengl-dev - Qt 4 OpenGL library development files
p libqt4-qt3support - Qt 3 compatibility library for Qt 4
p libqt4-ruby - ruby bindings for the Qt4 GUI library
p libqt4-ruby1.8 - Qt 4 bindings for Ruby
p libqt4-ruby1.8-dev - Qt 4 bindings for Ruby - development files
p libqt4-ruby1.8-examples - Qt 4 bindings for Ruby - example files
p libqt4-script - Qt 4 script module
p libqt4-scripttools - Qt 4 script tools module
p libqt4-sql - Qt 4 SQL module
p libqt4-sql-mysql - Qt 4 MySQL database driver
p libqt4-sql-odbc - Qt 4 ODBC database driver
p libqt4-sql-psql - Qt 4 PostgreSQL database driver
p libqt4-sql-sqlite - Qt 4 SQLite 3 database driver
p libqt4-sql-sqlite2 - Qt 4 SQLite 2 database driver
p libqt4-svg - Qt 4 SVG module
p libqt4-test - Qt 4 test module
p libqt4-webkit - Qt 4 WebKit module
p libqt4-webkit-dbg - Qt 4 WebKit library debugging symbols
p libqt4-xml - Qt 4 XML module
p libqt4-xmlpatterns - Qt 4 XML patterns module
p libqt4-xmlpatterns-dbg - Qt 4 XML patterns library debugging symbols
p libqwt5-qt4 - Qt4 widgets library for technical applicati
p libqwt5-qt4-dev - Qt4 widgets library for technical applicati
p libqwtplot3d-qt4 - 3D plotting library based on Qt4/OpenGL (ru
p libqwtplot3d-qt4-dev - 3D plotting library based on Qt4/OpenGL (de
p libsmokeqt4-2 - SMOKE Binding Library to Qt 4
p libsmokeqt4-2-dev - SMOKE Binding Library to Qt 4 - Development
p libsoqt4-20 - Qt4 GUI component toolkit for Inventor - ru
p libsoqt4-dev - Qt4 GUI component toolkit for Inventor - de
p libtulip-qt4-3.0-dev - Tulip graph library - Qt/OpenGL GUI develop
p libtulip-qt4-3.0.0b6 - Tulip graph library - Qt/OpenGL GUI runtime
p libvtk5-qt4 - Visualization Toolkit - A high level 3D vis
p libvtk5-qt4-dev - Visualization Toolkit - A high level 3D vis
p libzlui-qt4 - Qt4 interface module for ZLibrary
p lsb-qt4 - Linux Standard Base 3.2 Qt4 support package
v lsb-qt4-ia32 -
v lsb-qt4-noarch -
p pinentry-qt4 - Qt-4-based PIN or pass-phrase entry dialog
p pyqt4-dev-tools - Development tools for PyQt4
p python-qt4 - Python bindings for Qt4
p python-qt4-common - Shared files for PyQt4
p python-qt4-dbg - Python bindings for Qt4 (debug extensions)
p python-qt4-dbus - DBus Support for PyQt4
p python-qt4-dbus-dbg - DBus Support for PyQt4 (debug extensions)
p python-qt4-dev - Development files for PyQt4
p python-qt4-doc - Documentation and examples for PyQt4
p python-qt4-gl - Python bindings for Qt4’s OpenGL module
p python-qt4-gl-dbg - Python bindings for Qt4’s OpenGL module (de
p python-qt4-phonon - Python bindings for Phonon
p python-qt4-phonon-dbg - Python bindings for Phonon (debug extension
p python-qt4-sql - Python bindings for PyQt4’s SQL module
p python-qt4-sql-dbg - Python bindings for PyQt4’s SQL module (deb
p python-qwt3d-qt4 - Python bindings of the QwtPlot3D library
p python-qwt5-qt4 - Python version of the Qwt5 technical widget
v python2.5-qt4 -
v python2.5-qt4-dbus -
v python2.5-qt4-dbus-dbg -
v python2.5-qt4-gl -
v python2.5-qt4-phonon -
v python2.5-qt4-phonon-dbg -
v python2.5-qt4-sql -
v python2.6-qt4 -
v python2.6-qt4-dbus -
v python2.6-qt4-dbus-dbg -
v python2.6-qt4-gl -
v python2.6-qt4-phonon -
v python2.6-qt4-phonon-dbg -
v python2.6-qt4-sql -
p qt4-demos - Qt 4 examples and demos
p qt4-demos-dbg - Qt 4 examples and demos debugging symbols
p qt4-designer - graphical designer for Qt 4 applications
p qt4-dev-tools - Qt 4 development tools
p qt4-dev-tools-dbg - Qt 4 development tools debugging symbols
p qt4-doc - Qt 4 API documentation
p qt4-doc-html - Qt 4 API documentation (HTML format)
p qt4-qmake - Qt 4 qmake Makefile generator tool
p qt4-qtconfig - Qt 4 configuration tool
p scim-bridge-client-qt4 - IME server of scim-bridge communicate with
======================================================================
虽然网络上很多人使用 Redhat 或者Fedora 作为上位机操作系统,但是我觉得使用Ubuntu最为方便,因为需要的软件包大部分都可以通过 apt-get 方式来安装,而不必从源代码开始自己编译。要知道,自己编译源代码可不是一件轻松的事,因为在编译过程中经常会出现令人意外而且莫名其妙的错误。
我们使用的操作系统是 Ubuntu 8.04,使用目前最新版本的QT 4.4.0,安装起来即为简单,只要运行以下命令就行:
sudo apt-get install qt4-dev-tools qt4-doc qt4-qtconfig qt4-demos qt4-designer
注意在这个版本的软件包中,qt4-dev-tools 包含了Qt Assistant及Qt Linguist等工具,因此不需要单独安装这两个工具。其它的,qt4-doc 是帮助文档,包含了Qt中各个类库的详细说明以及丰富的例子程序,可以使用Qt Assistant 工具来打开阅读。qt4-qtconfig 是配置Qt环境的一个对话框,一般默认就行了,很少有必要去更改。qt4-demos 包含很多可以运行起来的可执行文件以及源代码。qt4-designer是用来设计GUI界面的设计器。
为了连接MySQL数据库,需要安装连接MySQL的驱动程序:
sudo apt-get install libqt4-sql-mysql
这些都可以使用一个命令搞定,而不需要自己从源码开始编译。在记不准或不知道名字的情况下,使用tab键列出所有可选的软件包是一个很实用的小技巧。
在我的项目中,还需要画一些数据曲线和统计图表等,而第三方的QWT库提供了这些功能。同样,只需要一个命令即可完成安装:
sudo apt-get install libqwt5-qt4 libqwt5-qt4-dev
这时,打开Qt Designer,就会发现左边的Widget列表里面多了“Qwt Widget”这一组。
最后,关于集成开发环境我觉得QDevelop很不错,它跟Qt Designer结合的很好,而且有提示类成员函数的功能。运行以下命令安装:
sudo apt-get install qdevelop
这样,使用Qdevelop编写代码和编译、调试,使用Qt Designer设计界面,开发效率较高。