您的位置:首页 > 编程语言 > Qt开发

Ubuntu下安装Qt4并创建简单窗口

2015-10-23 11:28 441 查看
环境:Ubuntu12

安装Qt4:sudo apt-get install qt4-dev-tools

完成后,创建工作目录,在目录下vi hello.cpp,写入

#include<qapplication.h>
#include<qpushbutton.h>
int main(int argc,char **argv)
{
QApplication app(argc,argv);
QPushButton hello("Hello world!",0);
hello.resize(100,30);
hello.show();
return app.exec();
}

在工作目录下依次执行以下命令:
qmake -project 此时目录下生成hello.pro文件

qmake hello.pro 此时目录下生成Makefile文件

make 此时目录下生成可执行文件hello

./hello 执行后显示出自己创建的窗口,里面有hello按钮
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  qt4 ubuntu