二、Ubuntu安装QT4
虽然本机装的是Gnome的Ubuntu,但也可以开发Qt程序,如果用一般的下载再编译Qt4,会弄很长的一段时间的。所以采用apt-get的方法安装Qt4。
运行:
$ sudo apt-get install libqt4-dev libqt4-debug libqt4-gui libqt4-sql qt4-dev-tools qt4-doc qt4-designer qt4-qtconfig
编写一个示例程序:
#include <QApplication>
#include <QPushButton>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QPushButton hello("Hello, man!"); hello.resize(100, 30);
hello.show(); return app.exec();
}
然后依次运行:
$ qmake -project
$ qmake
$ make
$ ./项目名
如下所示:
isp@hitisp:~/qtsrc$ vim QtHello.cpp
isp@hitisp:~/qtsrc$ qmake -project
isp@hitisp:~/qtsrc$ qmake
isp@hitisp:~/qtsrc$ make
运行结果是一个只有一个按钮的标题为项目名的小窗口。
