全部博文(30)
2012年(30)
分类: LINUX
2012-05-06 19:42:21
运行:
$ sudo apt-get install libqt4-dev libqt4-dbg libqt4-gui libqt4-sql qt4-dev-tools qt4-doc qt4-designer qt4-qtconfig
系统会自动安装及设置环境。这样速度会比较快,如果直接编译源码安装,要花费非常长的时间,真的深有体会。
编写一个示例程序:
#include
#include
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
$ ./项目名
如下所示:
vim QtHello.cpp
qmake -project
qmake
make
g++
-c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB
-I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore
-I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui
-I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. -o QtHello.o
QtHello.cpp
g++ -o qtsrc QtHello.o -L/usr/lib -lQtGui -lQtCore -lpthread
ls
Makefile QtHello.cpp QtHello.o qtsrc qtsrc.pro
./qtsrc