歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Linux下Qt編程(命令方式):Hello Qt!

Linux下Qt編程(命令方式):Hello Qt!

日期:2017/3/1 10:03:21   编辑:Linux編程

Linux:Ubuntu 11.10

Qt:Qt4集成開發環境(從ubuntu軟件中心下載)

1.新建文件夾:mkdir hello,在文件夾下創建文件: vim hello.cpp

2.在hello.cpp中輸入代碼:

#include <QApplication>
#include <QLabel>

int main(int argc,char *argv[])
{
QApplication app(argc,argv);
QLabel *label=new QLabel("Hello QT!");
label->show();
return app.exec();
}

3.在終端下輸入命令:qmake -project ,生成工程文件。此時在hello文件夾下生成hello.pro文件。

4.在終端下輸入命令:qmake hello.pro,生成Makefile

5.在終端下輸入命令:make ,進行編譯。生成hello可執行文件。

6.在終端下輸入命令:./hello ,運行程序。

Copyright © Linux教程網 All Rights Reserved