Ubuntu14.04下快速開發QT應用程式,ubuntu14.04qt

來源:互聯網
上載者:User

Ubuntu14.04下快速開發QT應用程式,ubuntu14.04qt

找要:示範如何快速開發QT應用。


1. Ubuntu下安裝QtIntegration Environment

  sudo apt-get install qt4-dev-tools qt4-doc qt4-qtconfig qt4-demos qt4-designer 

2. 編寫一個簡單的Qt程式

首先:建立一個應用檔案夾qtapp,並進入該檔案夾

cd ~

mkdir qtapp

cd qtapp

編寫程式:

gedit test1.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. 產生一個與平台無關的專案檔

 ~/qtapp$ qmake -project

得到了一個專案檔,名為:qtapp.pro

4. 產生makefile檔案
~/qtapp$ qmake qtapp.pro

得到Makefile檔案

5. 產生目標檔案

 ~/qtapp$ make

顯示資訊為:


g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -o test1.o test1.cpp
g++ -m64 -Wl,-O1 -o qtapp test1.o    -L/usr/lib/x86_64-linux-gnu -lQtGui -lQtCore -lpthread

得到qtapp可執行檔

6. 執行目標檔案

  ./qtapp

可見程式視窗(細心在螢幕上找一下,因為比較小)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.